@danielstyle/featflow 0.0.0-stage → 0.6.3
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/LICENSE +21 -0
- package/README.md +206 -2
- package/README.zh-CN.md +163 -0
- package/bin/featflow.mjs +113 -0
- package/package.json +62 -4
- package/skills/featflow/SKILL.md +127 -0
- package/skills/featflow-issues/SKILL.md +104 -0
- package/skills/featflow-regression/SKILL.md +63 -0
- package/src/agent-docs.mjs +143 -0
- package/src/changed-files.mjs +204 -0
- package/src/commands/cleanup.mjs +221 -0
- package/src/commands/codegraph.mjs +110 -0
- package/src/commands/doctor.mjs +265 -0
- package/src/commands/finish.mjs +249 -0
- package/src/commands/hook-cmd.mjs +78 -0
- package/src/commands/hooks-cmd.mjs +238 -0
- package/src/commands/init.mjs +382 -0
- package/src/commands/issue.mjs +434 -0
- package/src/commands/new.mjs +311 -0
- package/src/commands/plan-check.mjs +75 -0
- package/src/commands/policy-cmd.mjs +51 -0
- package/src/commands/pr-cleanup.mjs +194 -0
- package/src/commands/regression.mjs +206 -0
- package/src/commands/setup.mjs +343 -0
- package/src/commands/size-check.mjs +137 -0
- package/src/commands/status.mjs +100 -0
- package/src/commands/sync.mjs +407 -0
- package/src/commands/verify.mjs +206 -0
- package/src/commands/worktree.mjs +205 -0
- package/src/config.mjs +295 -0
- package/src/detect.mjs +314 -0
- package/src/git.mjs +331 -0
- package/src/hook-adapters.mjs +218 -0
- package/src/hooks-core.mjs +420 -0
- package/src/index.mjs +13 -0
- package/src/init-args.mjs +282 -0
- package/src/init-hooks.mjs +312 -0
- package/src/init-prompts.mjs +191 -0
- package/src/issues-helpers.mjs +463 -0
- package/src/issues.mjs +521 -0
- package/src/plan.mjs +202 -0
- package/src/policy.mjs +143 -0
- package/src/regression.mjs +338 -0
- package/src/size-check.mjs +203 -0
- package/src/tui-select.mjs +378 -0
- package/templates/adapters/antigravity/hooks.json +42 -0
- package/templates/adapters/claude-code/settings.json +46 -0
- package/templates/adapters/codex/config.toml +19 -0
- package/templates/adapters/cursor/hooks.json +27 -0
- package/templates/agents/codex/codebase-locator.toml +28 -0
- package/templates/agents/codex/implementation-scout.toml +28 -0
- package/templates/agents/codex/regression-guard-planner.toml +20 -0
- package/templates/features/README.md +56 -0
- package/templates/features/_program_template.md +79 -0
- package/templates/features/_template.md +120 -0
- package/templates/features/current-feature.md +18 -0
- package/templates/githooks/post-merge +7 -0
- package/templates/githooks/pre-commit +11 -0
- package/templates/githooks/pre-push +10 -0
- package/templates/regression/regression-ledger.yml +23 -0
- package/templates/snippets/AGENTS-workflow.md +21 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { loadConfig } from "../config.mjs";
|
|
2
|
+
import {
|
|
3
|
+
currentBranch,
|
|
4
|
+
fail,
|
|
5
|
+
findWorktreeForBranch,
|
|
6
|
+
gitConfigGet,
|
|
7
|
+
gitWorktrees,
|
|
8
|
+
isAncestor,
|
|
9
|
+
isInsidePath,
|
|
10
|
+
isTaskBranch,
|
|
11
|
+
localBranches,
|
|
12
|
+
localBranchExists,
|
|
13
|
+
runWrite,
|
|
14
|
+
statusShort,
|
|
15
|
+
} from "../git.mjs";
|
|
16
|
+
import { setupInstructions } from "../policy.mjs";
|
|
17
|
+
|
|
18
|
+
const usage = `
|
|
19
|
+
Usage:
|
|
20
|
+
featflow cleanup [options]
|
|
21
|
+
|
|
22
|
+
Removes local task branches and their clean worktrees once the branch tip is
|
|
23
|
+
already merged into the target base branch (developer branch in developer-branch
|
|
24
|
+
mode, or baseBranch in trunk mode). Never removes protected branches, unmerged
|
|
25
|
+
branches, dirty worktrees, or another developer's task branches.
|
|
26
|
+
|
|
27
|
+
Options:
|
|
28
|
+
--developer <branch> Override configured developer branch.
|
|
29
|
+
--dry-run Print mutating commands without running them.
|
|
30
|
+
--post-merge Run as a best-effort post-merge hook; only acts on the target branch.
|
|
31
|
+
-h, --help Show this help.
|
|
32
|
+
`.trim();
|
|
33
|
+
|
|
34
|
+
function parseArgs(argv) {
|
|
35
|
+
const options = {
|
|
36
|
+
developer: "",
|
|
37
|
+
dryRun: false,
|
|
38
|
+
postMerge: false,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
42
|
+
const arg = argv[i];
|
|
43
|
+
if (arg === "-h" || arg === "--help") {
|
|
44
|
+
console.log(usage);
|
|
45
|
+
process.exit(0);
|
|
46
|
+
}
|
|
47
|
+
if (arg === "--dry-run") {
|
|
48
|
+
options.dryRun = true;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (arg === "--post-merge") {
|
|
52
|
+
options.postMerge = true;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (arg === "--developer") {
|
|
56
|
+
options.developer = argv[++i] ?? "";
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (arg.startsWith("--developer=")) {
|
|
60
|
+
options.developer = arg.slice("--developer=".length);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
fail(`Unknown option: ${arg}`, usage);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return options;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function cleanupMergedTaskBranches({
|
|
70
|
+
cwd,
|
|
71
|
+
config,
|
|
72
|
+
targetBranch,
|
|
73
|
+
developerBranch = "",
|
|
74
|
+
dryRun = false,
|
|
75
|
+
excludeBranches = [],
|
|
76
|
+
quiet = false,
|
|
77
|
+
}) {
|
|
78
|
+
const current = currentBranch(cwd);
|
|
79
|
+
const excluded = new Set(excludeBranches);
|
|
80
|
+
const protectedSet = new Set(config.protectedBranches);
|
|
81
|
+
const result = {
|
|
82
|
+
errors: [],
|
|
83
|
+
removedBranches: [],
|
|
84
|
+
removedWorktrees: [],
|
|
85
|
+
skipped: [],
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
for (const taskBranch of localBranches(cwd)) {
|
|
89
|
+
if (
|
|
90
|
+
taskBranch === targetBranch ||
|
|
91
|
+
taskBranch === current ||
|
|
92
|
+
excluded.has(taskBranch) ||
|
|
93
|
+
protectedSet.has(taskBranch) ||
|
|
94
|
+
!isTaskBranch(taskBranch, config, developerBranch)
|
|
95
|
+
) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (!isAncestor(taskBranch, targetBranch, cwd)) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const worktree = findWorktreeForBranch(gitWorktrees(cwd), taskBranch);
|
|
104
|
+
if (worktree) {
|
|
105
|
+
if (isInsidePath(process.cwd(), worktree.path)) {
|
|
106
|
+
result.skipped.push({ branch: taskBranch, reason: "current-worktree", detail: worktree.path });
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const status = statusShort(worktree.path);
|
|
111
|
+
if (status) {
|
|
112
|
+
result.skipped.push({
|
|
113
|
+
branch: taskBranch,
|
|
114
|
+
reason: "dirty-worktree",
|
|
115
|
+
detail: `${worktree.path}\n${status}`,
|
|
116
|
+
});
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
runWrite("git", ["worktree", "remove", worktree.path], cwd, { dryRun });
|
|
122
|
+
result.removedWorktrees.push({ branch: taskBranch, path: worktree.path });
|
|
123
|
+
} catch (error) {
|
|
124
|
+
result.errors.push({
|
|
125
|
+
action: "worktree-remove",
|
|
126
|
+
branch: taskBranch,
|
|
127
|
+
message: error instanceof Error ? error.message : String(error),
|
|
128
|
+
});
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (!localBranchExists(taskBranch, cwd)) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
try {
|
|
138
|
+
runWrite("git", ["branch", "-d", taskBranch], cwd, { dryRun });
|
|
139
|
+
result.removedBranches.push(taskBranch);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
result.errors.push({
|
|
142
|
+
action: "branch-delete",
|
|
143
|
+
branch: taskBranch,
|
|
144
|
+
message: error instanceof Error ? error.message : String(error),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (!quiet) {
|
|
150
|
+
printCleanupSummary(result, { dryRun });
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function printCleanupSummary(result, { dryRun = false } = {}) {
|
|
157
|
+
const prefix = dryRun ? "Would clean" : "Cleaned";
|
|
158
|
+
for (const item of result.removedWorktrees) {
|
|
159
|
+
console.log(`${prefix} worktree for ${item.branch}: ${item.path}`);
|
|
160
|
+
}
|
|
161
|
+
for (const branch of result.removedBranches) {
|
|
162
|
+
console.log(`${prefix} merged task branch: ${branch}`);
|
|
163
|
+
}
|
|
164
|
+
for (const item of result.skipped) {
|
|
165
|
+
if (item.reason === "dirty-worktree") {
|
|
166
|
+
console.error(`Skipped ${item.branch}: worktree is dirty.\n${item.detail}`);
|
|
167
|
+
} else if (item.reason === "current-worktree") {
|
|
168
|
+
console.error(`Skipped ${item.branch}: current process is inside ${item.detail}`);
|
|
169
|
+
} else {
|
|
170
|
+
console.error(`Skipped ${item.branch}: ${item.reason}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
for (const item of result.errors) {
|
|
174
|
+
console.error(`Failed to ${item.action} for ${item.branch}: ${item.message}`);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (
|
|
178
|
+
result.removedBranches.length === 0 &&
|
|
179
|
+
result.removedWorktrees.length === 0 &&
|
|
180
|
+
result.skipped.length === 0 &&
|
|
181
|
+
result.errors.length === 0
|
|
182
|
+
) {
|
|
183
|
+
console.log("No merged local task branches to clean.");
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export async function runCleanup(argv) {
|
|
188
|
+
const options = parseArgs(argv);
|
|
189
|
+
const { config, repoRoot } = loadConfig(process.cwd());
|
|
190
|
+
|
|
191
|
+
let targetBranch = config.baseBranch;
|
|
192
|
+
let developerBranch = "";
|
|
193
|
+
|
|
194
|
+
if (config.mode === "developer-branch") {
|
|
195
|
+
developerBranch = options.developer || gitConfigGet(config.developerBranchConfigKey, repoRoot);
|
|
196
|
+
if (options.postMerge) {
|
|
197
|
+
if (!developerBranch || currentBranch(repoRoot) !== developerBranch) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
} else if (!developerBranch) {
|
|
201
|
+
fail(setupInstructions(config));
|
|
202
|
+
}
|
|
203
|
+
targetBranch = developerBranch;
|
|
204
|
+
} else if (options.postMerge) {
|
|
205
|
+
if (currentBranch(repoRoot) !== config.baseBranch) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const result = cleanupMergedTaskBranches({
|
|
211
|
+
cwd: repoRoot,
|
|
212
|
+
config,
|
|
213
|
+
targetBranch,
|
|
214
|
+
developerBranch,
|
|
215
|
+
dryRun: options.dryRun,
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
if (!options.postMerge && result.errors.length > 0) {
|
|
219
|
+
process.exit(1);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
import { commandExists, fail, findRepoRoot, runWrite } from "../git.mjs";
|
|
5
|
+
|
|
6
|
+
const usage = `
|
|
7
|
+
Usage:
|
|
8
|
+
featflow codegraph [bootstrap|status] [path] [options]
|
|
9
|
+
|
|
10
|
+
Initializes a local CodeGraph index when .codegraph/codegraph.db is missing,
|
|
11
|
+
or syncs the existing index when present. Skips cleanly in CI or when the
|
|
12
|
+
optional \`codegraph\` CLI is not installed.
|
|
13
|
+
|
|
14
|
+
Options:
|
|
15
|
+
--dry-run Print command without executing it
|
|
16
|
+
--json Output machine-readable JSON (for status)
|
|
17
|
+
-h, --help Show this help
|
|
18
|
+
|
|
19
|
+
Environment:
|
|
20
|
+
FEATFLOW_SKIP_CODEGRAPH=1 Skip CodeGraph bootstrap
|
|
21
|
+
CELHIVE_SKIP_CODEGRAPH=1 Skip CodeGraph bootstrap (legacy alias)
|
|
22
|
+
FEATFLOW_CODEGRAPH_IN_CI=1 Allow bootstrap in CI
|
|
23
|
+
CELHIVE_CODEGRAPH_BOOTSTRAP_IN_CI=1 Allow bootstrap in CI (legacy alias)
|
|
24
|
+
`.trim();
|
|
25
|
+
|
|
26
|
+
function parseArgs(argv) {
|
|
27
|
+
const options = {
|
|
28
|
+
subcommand: "bootstrap",
|
|
29
|
+
targetPath: "",
|
|
30
|
+
dryRun: false,
|
|
31
|
+
json: false,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
for (const arg of argv) {
|
|
35
|
+
if (arg === "-h" || arg === "--help") {
|
|
36
|
+
console.log(usage);
|
|
37
|
+
process.exit(0);
|
|
38
|
+
}
|
|
39
|
+
if (arg === "--dry-run") {
|
|
40
|
+
options.dryRun = true;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (arg === "--json") {
|
|
44
|
+
options.json = true;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (arg.startsWith("-")) {
|
|
48
|
+
fail(`Unknown option for codegraph: ${arg}`, usage);
|
|
49
|
+
}
|
|
50
|
+
if ((arg === "bootstrap" || arg === "status") && !options.targetPath && options.subcommand === "bootstrap") {
|
|
51
|
+
options.subcommand = arg;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (options.targetPath) {
|
|
55
|
+
fail(`Unexpected extra argument: ${arg}`, usage);
|
|
56
|
+
}
|
|
57
|
+
options.targetPath = arg;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return options;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function inspectCodegraphState(repoRoot) {
|
|
64
|
+
const installed = commandExists("codegraph");
|
|
65
|
+
const indexPath = path.join(repoRoot, ".codegraph", "codegraph.db");
|
|
66
|
+
const indexed = existsSync(indexPath);
|
|
67
|
+
return { installed, indexed, indexPath };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export async function runCodegraph(argv) {
|
|
71
|
+
const options = parseArgs(argv);
|
|
72
|
+
const requestedPath = path.resolve(options.targetPath || ".");
|
|
73
|
+
const repoRoot = findRepoRoot(requestedPath);
|
|
74
|
+
if (!repoRoot) {
|
|
75
|
+
fail(`Not inside a Git repository: ${requestedPath}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (options.subcommand === "status") {
|
|
79
|
+
const state = inspectCodegraphState(repoRoot);
|
|
80
|
+
if (options.json) {
|
|
81
|
+
console.log(JSON.stringify({ repoRoot, ...state }, null, 2));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
console.log(`CodeGraph CLI: ${state.installed ? "installed" : "not installed"}`);
|
|
85
|
+
console.log(`Local index: ${state.indexed ? `present (${state.indexPath})` : "not initialized"}`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const skipFlag = process.env.FEATFLOW_SKIP_CODEGRAPH || process.env.CELHIVE_SKIP_CODEGRAPH;
|
|
90
|
+
if (skipFlag === "1" || skipFlag === "true") {
|
|
91
|
+
console.log("Skipping CodeGraph bootstrap because FEATFLOW_SKIP_CODEGRAPH is set.");
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const allowInCi = process.env.FEATFLOW_CODEGRAPH_IN_CI === "1" || process.env.CELHIVE_CODEGRAPH_BOOTSTRAP_IN_CI === "1";
|
|
96
|
+
if (process.env.CI && !allowInCi) {
|
|
97
|
+
console.log("Skipping CodeGraph bootstrap in CI.");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const state = inspectCodegraphState(repoRoot);
|
|
102
|
+
if (!state.installed) {
|
|
103
|
+
console.log("CodeGraph CLI is not installed; skipping local index bootstrap.");
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const action = state.indexed ? "sync" : "init";
|
|
108
|
+
console.log(`CodeGraph ${action === "init" ? "initializing" : "syncing"} index for ${repoRoot}`);
|
|
109
|
+
runWrite("codegraph", [action, repoRoot], repoRoot, { dryRun: options.dryRun });
|
|
110
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
DEFAULT_AGENT_DOC_CANDIDATES,
|
|
7
|
+
findManagedAgentDocs,
|
|
8
|
+
inspectAgentDocBlock,
|
|
9
|
+
renderAgentWorkflowBlock,
|
|
10
|
+
} from "../agent-docs.mjs";
|
|
11
|
+
import { loadConfig } from "../config.mjs";
|
|
12
|
+
import { commandExists, findGitCommonDir, findRepoRoot, gitConfigGet, localBranchExists } from "../git.mjs";
|
|
13
|
+
import { validateActiveFeaturePlan } from "../plan.mjs";
|
|
14
|
+
import { inspectCodegraphState } from "./codegraph.mjs";
|
|
15
|
+
import { inspectSyncState } from "./sync.mjs";
|
|
16
|
+
|
|
17
|
+
const usage = `
|
|
18
|
+
Usage:
|
|
19
|
+
featflow doctor
|
|
20
|
+
|
|
21
|
+
Checks Git, .featflow.json, feature templates, skill installation (repo or global),
|
|
22
|
+
managed AGENTS.md / CLAUDE.md blocks, Git hooks, and active feature plan health.
|
|
23
|
+
`.trim();
|
|
24
|
+
|
|
25
|
+
function findGlobalSkillPath() {
|
|
26
|
+
const home = process.env.FEATFLOW_HOME || os.homedir();
|
|
27
|
+
if (!home) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const candidates = [
|
|
31
|
+
path.join(home, ".agents", "skills", "featflow", "SKILL.md"),
|
|
32
|
+
path.join(home, ".claude", "skills", "featflow", "SKILL.md"),
|
|
33
|
+
path.join(home, ".codex", "skills", "featflow", "SKILL.md"),
|
|
34
|
+
];
|
|
35
|
+
for (const candidate of candidates) {
|
|
36
|
+
if (existsSync(candidate)) {
|
|
37
|
+
const display = candidate.startsWith(home)
|
|
38
|
+
? `~${candidate.slice(home.length).replaceAll("\\", "/")}`
|
|
39
|
+
: candidate;
|
|
40
|
+
return { fullPath: candidate, display };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function runDoctor(argv) {
|
|
47
|
+
if (argv.includes("-h") || argv.includes("--help")) {
|
|
48
|
+
console.log(usage);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const checks = [];
|
|
53
|
+
const add = (status, label, detail) => checks.push({ status, label, detail });
|
|
54
|
+
|
|
55
|
+
add(commandExists("git") ? "PASS" : "FAIL", "Git CLI", commandExists("git") ? "available" : "git not found");
|
|
56
|
+
add(
|
|
57
|
+
commandExists("gh") ? "PASS" : "INFO",
|
|
58
|
+
"GitHub CLI (gh)",
|
|
59
|
+
commandExists("gh") ? "available (for issue & pr-cleanup)" : "optional — needed only for issue & pr-cleanup",
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const repoRoot = findRepoRoot(process.cwd());
|
|
63
|
+
if (!repoRoot) {
|
|
64
|
+
add("FAIL", "Git repository", "Not inside a Git repository.");
|
|
65
|
+
printChecks(checks);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let loaded;
|
|
70
|
+
try {
|
|
71
|
+
loaded = loadConfig(repoRoot);
|
|
72
|
+
add(
|
|
73
|
+
loaded.hasConfigFile ? "PASS" : "INFO",
|
|
74
|
+
"Config (.featflow.json)",
|
|
75
|
+
loaded.hasConfigFile
|
|
76
|
+
? `mode=${loaded.config.mode}`
|
|
77
|
+
: "not found (using global defaults; run `featflow init --minimal` to customize)",
|
|
78
|
+
);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
add("FAIL", "Config (.featflow.json)", error instanceof Error ? error.message : String(error));
|
|
81
|
+
printChecks(checks);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const { config } = loaded;
|
|
86
|
+
|
|
87
|
+
const templatePath = path.join(repoRoot, config.featuresDir, "_template.md");
|
|
88
|
+
const hasRepoTemplates =
|
|
89
|
+
existsSync(templatePath) ||
|
|
90
|
+
existsSync(path.join(repoRoot, config.featuresDir, "README.md")) ||
|
|
91
|
+
existsSync(path.join(repoRoot, config.featuresDir, "_program_template.md"));
|
|
92
|
+
|
|
93
|
+
if (existsSync(templatePath)) {
|
|
94
|
+
add("PASS", "Feature template", path.relative(repoRoot, templatePath));
|
|
95
|
+
} else {
|
|
96
|
+
add("PASS", "Feature template", "using built-in template (global/minimal mode)");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const repoSkillPath = path.join(repoRoot, ".agents", "skills", "featflow", "SKILL.md");
|
|
100
|
+
const hasRepoSkill = existsSync(repoSkillPath);
|
|
101
|
+
const globalSkill = hasRepoSkill ? null : findGlobalSkillPath();
|
|
102
|
+
if (hasRepoSkill) {
|
|
103
|
+
add("PASS", "Agent Skill", ".agents/skills/featflow/SKILL.md");
|
|
104
|
+
} else if (globalSkill) {
|
|
105
|
+
add("PASS", "Agent Skill", `global (${globalSkill.display})`);
|
|
106
|
+
} else {
|
|
107
|
+
add(
|
|
108
|
+
"WARN",
|
|
109
|
+
"Agent Skill",
|
|
110
|
+
"not found in repo or global skill dirs (run `npx skills add https://github.com/daniel-style/featflow --skill featflow -g` or `featflow init`)",
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const managedAgentDocs = findManagedAgentDocs(repoRoot);
|
|
115
|
+
if (managedAgentDocs.length > 0) {
|
|
116
|
+
const renderedBlock = renderAgentWorkflowBlock();
|
|
117
|
+
const driftedDocs = managedAgentDocs.filter(
|
|
118
|
+
(rel) => inspectAgentDocBlock(path.resolve(repoRoot, rel), renderedBlock).status !== "up-to-date",
|
|
119
|
+
);
|
|
120
|
+
if (driftedDocs.length === 0) {
|
|
121
|
+
add("PASS", "Agent docs", `${managedAgentDocs.join(", ")} (managed block up to date)`);
|
|
122
|
+
} else {
|
|
123
|
+
add("WARN", "Agent docs", `drifted: ${driftedDocs.join(", ")} (run \`featflow sync\`)`);
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
const existingRawDocs = DEFAULT_AGENT_DOC_CANDIDATES.filter((rel) => existsSync(path.join(repoRoot, rel)));
|
|
127
|
+
if (existingRawDocs.length > 0) {
|
|
128
|
+
add(
|
|
129
|
+
"INFO",
|
|
130
|
+
"Agent docs",
|
|
131
|
+
`${existingRawDocs.join(", ")} has no featflow managed block (run \`featflow sync --only agent-docs\`)`,
|
|
132
|
+
);
|
|
133
|
+
} else {
|
|
134
|
+
add("INFO", "Agent docs", "no AGENTS.md/CLAUDE.md managed block (run `featflow sync --only agent-docs` or `featflow init`)");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const hasIssuesSkill = existsSync(path.join(repoRoot, ".agents", "skills", "featflow-issues", "SKILL.md"));
|
|
139
|
+
const hasRegressionSkill = existsSync(path.join(repoRoot, ".agents", "skills", "featflow-regression", "SKILL.md"));
|
|
140
|
+
if (config.issues) {
|
|
141
|
+
const assetsDetail = config.issues.assetsRepo ? `, assetsRepo=${config.issues.assetsRepo}` : "";
|
|
142
|
+
add("PASS", "Issues workflow", `enabled (${config.issues.provider}${assetsDetail})`);
|
|
143
|
+
}
|
|
144
|
+
if (config.fileSizeBudget) {
|
|
145
|
+
const preCommitTag = config.fileSizeBudget.enforceInPreCommit ? ", pre-commit=on" : "";
|
|
146
|
+
add(
|
|
147
|
+
"PASS",
|
|
148
|
+
"File size budget",
|
|
149
|
+
`enabled (prod=${config.fileSizeBudget.production}, style=${config.fileSizeBudget.style}, test=${config.fileSizeBudget.test}${preCommitTag})`,
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
if (config.regression) {
|
|
153
|
+
const ledgerExists = existsSync(path.resolve(repoRoot, config.regression.ledgerFile));
|
|
154
|
+
add(
|
|
155
|
+
ledgerExists ? "PASS" : "WARN",
|
|
156
|
+
"Regression ledger",
|
|
157
|
+
ledgerExists ? config.regression.ledgerFile : `configured "${config.regression.ledgerFile}" not found`,
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const configuredAgentHooks = [];
|
|
162
|
+
if (existsSync(path.join(repoRoot, ".agents", "hooks.json"))) configuredAgentHooks.push("antigravity");
|
|
163
|
+
if (existsSync(path.join(repoRoot, ".claude", "settings.json"))) configuredAgentHooks.push("claude-code");
|
|
164
|
+
if (existsSync(path.join(repoRoot, ".codex", "config.toml"))) configuredAgentHooks.push("codex");
|
|
165
|
+
if (existsSync(path.join(repoRoot, ".cursor", "hooks.json"))) configuredAgentHooks.push("cursor");
|
|
166
|
+
if (configuredAgentHooks.length > 0) {
|
|
167
|
+
add("PASS", "AI Agent hooks", configuredAgentHooks.join(", "));
|
|
168
|
+
} else {
|
|
169
|
+
add("INFO", "AI Agent hooks", "none installed (run `featflow init --merge --with-all-hooks` or interactive `featflow init --merge`)");
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const cg = inspectCodegraphState(repoRoot);
|
|
173
|
+
if (cg.installed) {
|
|
174
|
+
add("PASS", "CodeGraph", cg.indexed ? "CLI available, local index present" : "CLI available (run `featflow codegraph` to index)");
|
|
175
|
+
} else {
|
|
176
|
+
add("INFO", "CodeGraph", "optional — CLI not installed");
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const syncGroups = new Set();
|
|
180
|
+
if (hasRepoSkill) {
|
|
181
|
+
syncGroups.add("skill");
|
|
182
|
+
}
|
|
183
|
+
if (hasIssuesSkill || (Boolean(config.issues) && (hasRepoSkill || hasRepoTemplates))) {
|
|
184
|
+
syncGroups.add("issues-skill");
|
|
185
|
+
}
|
|
186
|
+
if (hasRegressionSkill) {
|
|
187
|
+
syncGroups.add("regression-skill");
|
|
188
|
+
}
|
|
189
|
+
if (hasRepoTemplates) {
|
|
190
|
+
syncGroups.add("templates");
|
|
191
|
+
}
|
|
192
|
+
if (existsSync(path.join(repoRoot, ".githooks"))) {
|
|
193
|
+
syncGroups.add("githooks");
|
|
194
|
+
}
|
|
195
|
+
if (managedAgentDocs.length > 0) {
|
|
196
|
+
syncGroups.add("agent-docs");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (syncGroups.size === 0) {
|
|
200
|
+
add("PASS", "Managed files sync", "zero-footprint mode (no repo-managed files)");
|
|
201
|
+
} else {
|
|
202
|
+
const syncState = inspectSyncState(repoRoot, config, syncGroups);
|
|
203
|
+
if (syncState.ok) {
|
|
204
|
+
add("PASS", "Managed files sync", `${syncState.upToDate.length} files match installed featflow`);
|
|
205
|
+
} else {
|
|
206
|
+
const issues = [
|
|
207
|
+
...syncState.missing.map((item) => `missing ${item.rel}`),
|
|
208
|
+
...syncState.drifted.map((item) => `drifted ${item.rel}`),
|
|
209
|
+
];
|
|
210
|
+
add("WARN", "Managed files sync", `${issues.join(", ")} (run \`featflow sync\`)`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const hooksPath = gitConfigGet("core.hooksPath", repoRoot);
|
|
215
|
+
const commonDir = findGitCommonDir(repoRoot);
|
|
216
|
+
const localPreCommit = commonDir ? path.join(commonDir, "hooks", "pre-commit") : "";
|
|
217
|
+
const hasLocalHook = Boolean(localPreCommit && existsSync(localPreCommit) && readFileSync(localPreCommit, "utf8").includes("featflow managed hook"));
|
|
218
|
+
if (hooksPath === ".githooks") {
|
|
219
|
+
add("PASS", "Git hooks", "core.hooksPath=.githooks");
|
|
220
|
+
} else if (hooksPath) {
|
|
221
|
+
add("INFO", "Git hooks", `external hooks manager detected (core.hooksPath=${hooksPath})`);
|
|
222
|
+
} else if (hasLocalHook) {
|
|
223
|
+
add("PASS", "Git hooks", "local .git/hooks managed blocks installed");
|
|
224
|
+
} else {
|
|
225
|
+
add("INFO", "Git hooks", "not configured (run `featflow hooks install --local` or `featflow init --with-githooks`)");
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (config.mode === "developer-branch") {
|
|
229
|
+
const devBranch = gitConfigGet(config.developerBranchConfigKey, repoRoot);
|
|
230
|
+
if (!devBranch) {
|
|
231
|
+
add("FAIL", "Developer branch", `not configured (run \`featflow setup <your-branch>\`)`);
|
|
232
|
+
} else if (!localBranchExists(devBranch, repoRoot)) {
|
|
233
|
+
add("FAIL", "Developer branch", `configured "${devBranch}" does not exist locally`);
|
|
234
|
+
} else {
|
|
235
|
+
add("PASS", "Developer branch", devBranch);
|
|
236
|
+
}
|
|
237
|
+
} else {
|
|
238
|
+
add(
|
|
239
|
+
localBranchExists(config.baseBranch, repoRoot) ? "PASS" : "WARN",
|
|
240
|
+
"Base branch",
|
|
241
|
+
localBranchExists(config.baseBranch, repoRoot) ? config.baseBranch : `local branch "${config.baseBranch}" not found yet`,
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const plan = validateActiveFeaturePlan(repoRoot, { featuresDir: config.featuresDir });
|
|
246
|
+
if (plan.skipped) {
|
|
247
|
+
add("PASS", "Active feature plan", "no active feature record");
|
|
248
|
+
} else if (plan.ok) {
|
|
249
|
+
add("PASS", "Active feature plan", `${plan.activeFeature} is complete and approved`);
|
|
250
|
+
} else {
|
|
251
|
+
add("WARN", "Active feature plan", `${plan.activeFeature}: ${plan.errors.join("; ")}`);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
printChecks(checks);
|
|
255
|
+
|
|
256
|
+
if (checks.some((item) => item.status === "FAIL")) {
|
|
257
|
+
process.exit(1);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function printChecks(checks) {
|
|
262
|
+
for (const item of checks) {
|
|
263
|
+
console.log(`[${item.status}] ${item.label}: ${item.detail}`);
|
|
264
|
+
}
|
|
265
|
+
}
|