@danielstyle/featflow 0.6.3 → 0.6.4
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/README.md +63 -20
- package/README.zh-CN.md +106 -19
- package/bin/featflow.mjs +3 -0
- package/package.json +3 -2
- package/src/commands/codegraph.mjs +2 -4
- package/src/commands/doctor.mjs +77 -39
- package/src/commands/hooks-cmd.mjs +9 -0
- package/src/commands/init.mjs +113 -18
- package/src/commands/policy-cmd.mjs +6 -2
- package/src/commands/skills.mjs +181 -0
- package/src/commands/sync.mjs +19 -5
- package/src/hooks-core.mjs +2 -2
- package/src/index.mjs +1 -0
- package/src/init-args.mjs +14 -2
- package/src/init-prompts.mjs +3 -3
- package/src/skills-manager.mjs +348 -0
- package/templates/githooks/post-merge +3 -0
- package/templates/githooks/pre-commit +4 -1
- package/templates/githooks/pre-push +3 -0
- package/templates/snippets/AGENTS-workflow.md +1 -1
package/src/commands/doctor.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import os from "node:os";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
|
|
5
4
|
import {
|
|
@@ -11,6 +10,11 @@ import {
|
|
|
11
10
|
import { loadConfig } from "../config.mjs";
|
|
12
11
|
import { commandExists, findGitCommonDir, findRepoRoot, gitConfigGet, localBranchExists } from "../git.mjs";
|
|
13
12
|
import { validateActiveFeaturePlan } from "../plan.mjs";
|
|
13
|
+
import {
|
|
14
|
+
inspectCliAvailability,
|
|
15
|
+
inspectSkillsStatus,
|
|
16
|
+
requiredSkillsForConfig,
|
|
17
|
+
} from "../skills-manager.mjs";
|
|
14
18
|
import { inspectCodegraphState } from "./codegraph.mjs";
|
|
15
19
|
import { inspectSyncState } from "./sync.mjs";
|
|
16
20
|
|
|
@@ -18,31 +22,11 @@ const usage = `
|
|
|
18
22
|
Usage:
|
|
19
23
|
featflow doctor
|
|
20
24
|
|
|
21
|
-
Checks Git, .featflow.json, feature templates,
|
|
22
|
-
|
|
25
|
+
Checks Git, featflow CLI availability, .featflow.json, feature templates,
|
|
26
|
+
global/repo Agent Skills (including drift & shadowing), managed AGENTS.md /
|
|
27
|
+
CLAUDE.md blocks, Git & AI agent hooks, and active feature plan health.
|
|
23
28
|
`.trim();
|
|
24
29
|
|
|
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
30
|
export async function runDoctor(argv) {
|
|
47
31
|
if (argv.includes("-h") || argv.includes("--help")) {
|
|
48
32
|
console.log(usage);
|
|
@@ -66,6 +50,27 @@ export async function runDoctor(argv) {
|
|
|
66
50
|
process.exit(1);
|
|
67
51
|
}
|
|
68
52
|
|
|
53
|
+
const configuredAgentHooks = [];
|
|
54
|
+
if (existsSync(path.join(repoRoot, ".agents", "hooks.json"))) configuredAgentHooks.push("antigravity");
|
|
55
|
+
if (existsSync(path.join(repoRoot, ".claude", "settings.json"))) configuredAgentHooks.push("claude-code");
|
|
56
|
+
if (existsSync(path.join(repoRoot, ".codex", "config.toml"))) configuredAgentHooks.push("codex");
|
|
57
|
+
if (existsSync(path.join(repoRoot, ".cursor", "hooks.json"))) configuredAgentHooks.push("cursor");
|
|
58
|
+
|
|
59
|
+
const cliState = inspectCliAvailability(repoRoot);
|
|
60
|
+
if (cliState.onPath) {
|
|
61
|
+
add("PASS", "featflow CLI", "available on PATH");
|
|
62
|
+
} else if (configuredAgentHooks.length > 0) {
|
|
63
|
+
add(
|
|
64
|
+
"WARN",
|
|
65
|
+
"featflow CLI",
|
|
66
|
+
"not on PATH (configured AI agent hooks invoke `featflow hook ...` directly; run `npm install -g @danielstyle/featflow`)",
|
|
67
|
+
);
|
|
68
|
+
} else if (cliState.localBin || cliState.mainLocalBin) {
|
|
69
|
+
add("PASS", "featflow CLI", "available via local node_modules/.bin/featflow");
|
|
70
|
+
} else {
|
|
71
|
+
add("INFO", "featflow CLI", "not on PATH (install globally via `npm install -g @danielstyle/featflow` for direct shell/hook usage)");
|
|
72
|
+
}
|
|
73
|
+
|
|
69
74
|
let loaded;
|
|
70
75
|
try {
|
|
71
76
|
loaded = loadConfig(repoRoot);
|
|
@@ -96,18 +101,55 @@ export async function runDoctor(argv) {
|
|
|
96
101
|
add("PASS", "Feature template", "using built-in template (global/minimal mode)");
|
|
97
102
|
}
|
|
98
103
|
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
const requiredSkills = requiredSkillsForConfig(config);
|
|
105
|
+
const ensureAgents = [
|
|
106
|
+
"agents",
|
|
107
|
+
...(configuredAgentHooks.includes("claude-code") ? ["claude-code"] : []),
|
|
108
|
+
...(configuredAgentHooks.includes("codex") ? ["codex"] : []),
|
|
109
|
+
...(configuredAgentHooks.includes("cursor") ? ["cursor"] : []),
|
|
110
|
+
];
|
|
111
|
+
const skillReport = inspectSkillsStatus({
|
|
112
|
+
repoRoot,
|
|
113
|
+
skillNames: requiredSkills,
|
|
114
|
+
ensureAgents,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const allInRepo = skillReport.skills.every((s) => s.hasRepoCopy);
|
|
118
|
+
if (allInRepo) {
|
|
119
|
+
add("PASS", "Agent Skill", `repo (.agents/skills/: ${requiredSkills.join(", ")})`);
|
|
120
|
+
const staleShadows = skillReport.skills.filter((s) => s.repoStaleShadow).map((s) => s.name);
|
|
121
|
+
if (staleShadows.length > 0) {
|
|
122
|
+
add(
|
|
123
|
+
"WARN",
|
|
124
|
+
"Skill precedence",
|
|
125
|
+
`repo .agents/skills/ (${staleShadows.join(", ")}) is outdated and shadows global skills (run \`featflow sync\` or remove repo copies to follow global updates)`,
|
|
126
|
+
);
|
|
127
|
+
} else if (skillReport.shadowedSkills.length > 0) {
|
|
128
|
+
add(
|
|
129
|
+
"INFO",
|
|
130
|
+
"Skill precedence",
|
|
131
|
+
`repo .agents/skills/ (${skillReport.shadowedSkills.join(", ")}) takes precedence over global skills in this repo`,
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
} else if (skillReport.allGlobalReady) {
|
|
135
|
+
add(
|
|
136
|
+
"PASS",
|
|
137
|
+
"Agent Skill",
|
|
138
|
+
`global (${requiredSkills.join(", ")} in ${skillReport.targets.map((t) => t.displayDir).join(", ")})`,
|
|
139
|
+
);
|
|
106
140
|
} else {
|
|
141
|
+
const parts = [];
|
|
142
|
+
if (skillReport.missingSkills.length > 0) {
|
|
143
|
+
parts.push(`missing: ${skillReport.missingSkills.join(", ")}`);
|
|
144
|
+
}
|
|
145
|
+
if (skillReport.driftedSkills.length > 0) {
|
|
146
|
+
parts.push(`outdated: ${skillReport.driftedSkills.join(", ")}`);
|
|
147
|
+
}
|
|
148
|
+
const pending = [...new Set([...skillReport.missingSkills, ...skillReport.driftedSkills])];
|
|
107
149
|
add(
|
|
108
150
|
"WARN",
|
|
109
151
|
"Agent Skill",
|
|
110
|
-
"
|
|
152
|
+
`${parts.join("; ")} (run \`featflow skills install\` or \`npx skills add https://github.com/daniel-style/featflow --skill ${pending.join(" ")} -g\`)`,
|
|
111
153
|
);
|
|
112
154
|
}
|
|
113
155
|
|
|
@@ -135,6 +177,7 @@ export async function runDoctor(argv) {
|
|
|
135
177
|
}
|
|
136
178
|
}
|
|
137
179
|
|
|
180
|
+
const hasRepoSkill = existsSync(path.join(repoRoot, ".agents", "skills", "featflow", "SKILL.md"));
|
|
138
181
|
const hasIssuesSkill = existsSync(path.join(repoRoot, ".agents", "skills", "featflow-issues", "SKILL.md"));
|
|
139
182
|
const hasRegressionSkill = existsSync(path.join(repoRoot, ".agents", "skills", "featflow-regression", "SKILL.md"));
|
|
140
183
|
if (config.issues) {
|
|
@@ -158,11 +201,6 @@ export async function runDoctor(argv) {
|
|
|
158
201
|
);
|
|
159
202
|
}
|
|
160
203
|
|
|
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
204
|
if (configuredAgentHooks.length > 0) {
|
|
167
205
|
add("PASS", "AI Agent hooks", configuredAgentHooks.join(", "));
|
|
168
206
|
} else {
|
|
@@ -180,10 +218,10 @@ export async function runDoctor(argv) {
|
|
|
180
218
|
if (hasRepoSkill) {
|
|
181
219
|
syncGroups.add("skill");
|
|
182
220
|
}
|
|
183
|
-
if (hasIssuesSkill || (Boolean(config.issues) &&
|
|
221
|
+
if (hasIssuesSkill || (Boolean(config.issues) && hasRepoSkill)) {
|
|
184
222
|
syncGroups.add("issues-skill");
|
|
185
223
|
}
|
|
186
|
-
if (hasRegressionSkill) {
|
|
224
|
+
if (hasRegressionSkill || (Boolean(config.regression) && hasRepoSkill)) {
|
|
187
225
|
syncGroups.add("regression-skill");
|
|
188
226
|
}
|
|
189
227
|
if (hasRepoTemplates) {
|
|
@@ -10,8 +10,11 @@ const BLOCK_END = "# <<< featflow managed hook <<<";
|
|
|
10
10
|
const HOOK_SNIPPETS = {
|
|
11
11
|
"pre-commit": [
|
|
12
12
|
BLOCK_START,
|
|
13
|
+
'_ff_common_dir="$(git rev-parse --git-common-dir 2>/dev/null || true)"',
|
|
13
14
|
'if [ -x "./node_modules/.bin/featflow" ]; then',
|
|
14
15
|
" ./node_modules/.bin/featflow policy pre-commit || exit $?",
|
|
16
|
+
'elif [ -n "$_ff_common_dir" ] && [ -x "$_ff_common_dir/../node_modules/.bin/featflow" ]; then',
|
|
17
|
+
' "$_ff_common_dir/../node_modules/.bin/featflow" policy pre-commit || exit $?',
|
|
15
18
|
"elif command -v featflow >/dev/null 2>&1; then",
|
|
16
19
|
" featflow policy pre-commit || exit $?",
|
|
17
20
|
"fi",
|
|
@@ -19,8 +22,11 @@ const HOOK_SNIPPETS = {
|
|
|
19
22
|
].join("\n"),
|
|
20
23
|
"pre-push": [
|
|
21
24
|
BLOCK_START,
|
|
25
|
+
'_ff_common_dir="$(git rev-parse --git-common-dir 2>/dev/null || true)"',
|
|
22
26
|
'if [ -x "./node_modules/.bin/featflow" ]; then',
|
|
23
27
|
" ./node_modules/.bin/featflow policy pre-push || exit $?",
|
|
28
|
+
'elif [ -n "$_ff_common_dir" ] && [ -x "$_ff_common_dir/../node_modules/.bin/featflow" ]; then',
|
|
29
|
+
' "$_ff_common_dir/../node_modules/.bin/featflow" policy pre-push || exit $?',
|
|
24
30
|
"elif command -v featflow >/dev/null 2>&1; then",
|
|
25
31
|
" featflow policy pre-push || exit $?",
|
|
26
32
|
"fi",
|
|
@@ -28,8 +34,11 @@ const HOOK_SNIPPETS = {
|
|
|
28
34
|
].join("\n"),
|
|
29
35
|
"post-merge": [
|
|
30
36
|
BLOCK_START,
|
|
37
|
+
'_ff_common_dir="$(git rev-parse --git-common-dir 2>/dev/null || true)"',
|
|
31
38
|
'if [ -x "./node_modules/.bin/featflow" ]; then',
|
|
32
39
|
" ./node_modules/.bin/featflow cleanup --post-merge || true",
|
|
40
|
+
'elif [ -n "$_ff_common_dir" ] && [ -x "$_ff_common_dir/../node_modules/.bin/featflow" ]; then',
|
|
41
|
+
' "$_ff_common_dir/../node_modules/.bin/featflow" cleanup --post-merge || true',
|
|
33
42
|
"elif command -v featflow >/dev/null 2>&1; then",
|
|
34
43
|
" featflow cleanup --post-merge || true",
|
|
35
44
|
"fi",
|
package/src/commands/init.mjs
CHANGED
|
@@ -26,6 +26,13 @@ import {
|
|
|
26
26
|
} from "../init-hooks.mjs";
|
|
27
27
|
import { promptInteractiveOptions } from "../init-prompts.mjs";
|
|
28
28
|
import { evaluateFileSizeBudget, updateFileSizeBaseline } from "../size-check.mjs";
|
|
29
|
+
import {
|
|
30
|
+
inspectCliAvailability,
|
|
31
|
+
inspectSkillsStatus,
|
|
32
|
+
installGlobalSkills,
|
|
33
|
+
mapHookAgentsToSkillTargets,
|
|
34
|
+
requiredSkillsForConfig,
|
|
35
|
+
} from "../skills-manager.mjs";
|
|
29
36
|
import { createSmartPrompter, promptSingleSelect } from "../tui-select.mjs";
|
|
30
37
|
import { configureGitHooksSafely, installLocalHooks } from "./hooks-cmd.mjs";
|
|
31
38
|
import { setupDeveloperBranchWorkflow } from "./setup.mjs";
|
|
@@ -175,34 +182,37 @@ export async function runInit(argv) {
|
|
|
175
182
|
skipped,
|
|
176
183
|
);
|
|
177
184
|
}
|
|
178
|
-
|
|
179
|
-
copyTemplateFile(
|
|
180
|
-
path.join(packageRoot, "skills", "featflow", "SKILL.md"),
|
|
181
|
-
path.join(repoRoot, ".agents", "skills", "featflow", "SKILL.md"),
|
|
182
|
-
options.force,
|
|
183
|
-
created,
|
|
184
|
-
skipped,
|
|
185
|
-
);
|
|
186
185
|
}
|
|
187
186
|
|
|
188
187
|
if (!options.minimal) {
|
|
189
|
-
if (options.
|
|
188
|
+
if (options.withRepoSkills) {
|
|
190
189
|
copyTemplateFile(
|
|
191
|
-
path.join(packageRoot, "skills", "featflow
|
|
192
|
-
path.join(repoRoot, ".agents", "skills", "featflow
|
|
190
|
+
path.join(packageRoot, "skills", "featflow", "SKILL.md"),
|
|
191
|
+
path.join(repoRoot, ".agents", "skills", "featflow", "SKILL.md"),
|
|
193
192
|
options.force,
|
|
194
193
|
created,
|
|
195
194
|
skipped,
|
|
196
195
|
);
|
|
196
|
+
if (options.withIssues || config.issues) {
|
|
197
|
+
copyTemplateFile(
|
|
198
|
+
path.join(packageRoot, "skills", "featflow-issues", "SKILL.md"),
|
|
199
|
+
path.join(repoRoot, ".agents", "skills", "featflow-issues", "SKILL.md"),
|
|
200
|
+
options.force,
|
|
201
|
+
created,
|
|
202
|
+
skipped,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
if (options.withRegression || config.regression) {
|
|
206
|
+
copyTemplateFile(
|
|
207
|
+
path.join(packageRoot, "skills", "featflow-regression", "SKILL.md"),
|
|
208
|
+
path.join(repoRoot, ".agents", "skills", "featflow-regression", "SKILL.md"),
|
|
209
|
+
options.force,
|
|
210
|
+
created,
|
|
211
|
+
skipped,
|
|
212
|
+
);
|
|
213
|
+
}
|
|
197
214
|
}
|
|
198
215
|
if (options.withRegression) {
|
|
199
|
-
copyTemplateFile(
|
|
200
|
-
path.join(packageRoot, "skills", "featflow-regression", "SKILL.md"),
|
|
201
|
-
path.join(repoRoot, ".agents", "skills", "featflow-regression", "SKILL.md"),
|
|
202
|
-
options.force,
|
|
203
|
-
created,
|
|
204
|
-
skipped,
|
|
205
|
-
);
|
|
206
216
|
installInitialRegressionLedger(
|
|
207
217
|
repoRoot,
|
|
208
218
|
config.regression?.ledgerFile || DEFAULT_REGRESSION_CONFIG.ledgerFile,
|
|
@@ -332,6 +342,84 @@ export async function runInit(argv) {
|
|
|
332
342
|
}
|
|
333
343
|
}
|
|
334
344
|
|
|
345
|
+
let skillSummary = "";
|
|
346
|
+
let needsGlobalSkillInstall = false;
|
|
347
|
+
const requiredSkills = requiredSkillsForConfig(config);
|
|
348
|
+
const ensureSkillAgents = mapHookAgentsToSkillTargets(options);
|
|
349
|
+
if (!options.withRepoSkills) {
|
|
350
|
+
const skillReport = inspectSkillsStatus({
|
|
351
|
+
repoRoot,
|
|
352
|
+
skillNames: requiredSkills,
|
|
353
|
+
ensureAgents: ensureSkillAgents,
|
|
354
|
+
});
|
|
355
|
+
if (skillReport.allGlobalReady) {
|
|
356
|
+
skillSummary = `Global skills ready: ${requiredSkills.join(", ")} (${skillReport.targets.map((t) => t.displayDir).join(", ")})`;
|
|
357
|
+
} else {
|
|
358
|
+
const pendingNames = [...new Set([...skillReport.missingSkills, ...skillReport.driftedSkills])];
|
|
359
|
+
let shouldSyncGlobal = options.installGlobalSkills;
|
|
360
|
+
if (!shouldSyncGlobal && prompter) {
|
|
361
|
+
const answer = await promptSingleSelect(prompter, {
|
|
362
|
+
title: `Global skills need install/update (${pendingNames.join(", ")}). Sync now?`,
|
|
363
|
+
defaultId: "yes",
|
|
364
|
+
choices: [
|
|
365
|
+
{
|
|
366
|
+
id: "yes",
|
|
367
|
+
label: "Yes",
|
|
368
|
+
detail: `sync to ${skillReport.targets.map((t) => t.displayDir).join(", ")} (offline, matches CLI)`,
|
|
369
|
+
aliases: ["y", "true"],
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
id: "no",
|
|
373
|
+
label: "No",
|
|
374
|
+
detail: "skip for now (run `featflow skills install` later)",
|
|
375
|
+
aliases: ["n", "false"],
|
|
376
|
+
},
|
|
377
|
+
],
|
|
378
|
+
});
|
|
379
|
+
shouldSyncGlobal = answer === "yes";
|
|
380
|
+
}
|
|
381
|
+
if (shouldSyncGlobal) {
|
|
382
|
+
const syncRes = installGlobalSkills({
|
|
383
|
+
skillNames: requiredSkills,
|
|
384
|
+
ensureAgents: ensureSkillAgents,
|
|
385
|
+
});
|
|
386
|
+
const touched = syncRes.installed.length + syncRes.updated.length;
|
|
387
|
+
skillSummary = `Synced global skills (${touched} file(s) across ${syncRes.targets.map((t) => t.displayDir).join(", ")})`;
|
|
388
|
+
} else {
|
|
389
|
+
needsGlobalSkillInstall = true;
|
|
390
|
+
notices.push(
|
|
391
|
+
[
|
|
392
|
+
`Global skills missing or outdated for this repo: ${pendingNames.join(", ")}.`,
|
|
393
|
+
"Run `featflow skills install` (offline, syncs all detected agents) or `npx skills add https://github.com/daniel-style/featflow --skill " +
|
|
394
|
+
requiredSkills.join(" ") +
|
|
395
|
+
" -g`.",
|
|
396
|
+
].join("\n"),
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (skillReport.shadowedSkills.length > 0) {
|
|
401
|
+
notices.push(
|
|
402
|
+
`Existing repo-level .agents/skills/ copies detected (${skillReport.shadowedSkills.join(", ")}); they take precedence over global skills until removed or updated via \`featflow sync\`.`,
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
const cliState = inspectCliAvailability(repoRoot);
|
|
408
|
+
const hasAgentHooks =
|
|
409
|
+
options.withAntigravityHooks ||
|
|
410
|
+
options.withClaudeHooks ||
|
|
411
|
+
options.withCodexHooks ||
|
|
412
|
+
options.withCursorHooks;
|
|
413
|
+
const needsGlobalCli = !cliState.onPath && (hasAgentHooks || (!cliState.localBin && !cliState.mainLocalBin));
|
|
414
|
+
if (!cliState.onPath && hasAgentHooks) {
|
|
415
|
+
notices.push(
|
|
416
|
+
[
|
|
417
|
+
"[WARN] `featflow` CLI is not on your global PATH, while AI coding-agent hooks invoke `featflow hook ...` directly.",
|
|
418
|
+
"Install globally so hooks and agents work across all worktrees: npm install -g @danielstyle/featflow",
|
|
419
|
+
].join("\n"),
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
|
|
335
423
|
const actionVerb = options.merge && existingConfig ? "Upgraded" : "Initialized";
|
|
336
424
|
const profileLabel = options.minimal ? "minimal" : options.preset || "full";
|
|
337
425
|
console.log(`${actionVerb} featflow in ${repoRoot} (mode: ${config.mode}, profile: ${profileLabel})`);
|
|
@@ -356,6 +444,7 @@ export async function runInit(argv) {
|
|
|
356
444
|
}
|
|
357
445
|
if (ignoredAdded.length > 0) console.log(`Updated .gitignore with: ${ignoredAdded.join(", ")}`);
|
|
358
446
|
if (hookNotice) console.log(`\n${hookNotice}`);
|
|
447
|
+
if (skillSummary) console.log(`\n${skillSummary}`);
|
|
359
448
|
if (devSetupSummary) console.log(`\n${devSetupSummary}`);
|
|
360
449
|
for (const notice of notices) console.log(`\n${notice}`);
|
|
361
450
|
|
|
@@ -366,6 +455,12 @@ export async function runInit(argv) {
|
|
|
366
455
|
|
|
367
456
|
console.log("\nNext steps:");
|
|
368
457
|
const steps = [];
|
|
458
|
+
if (needsGlobalCli) {
|
|
459
|
+
steps.push("Ensure featflow CLI is on PATH: npm install -g @danielstyle/featflow");
|
|
460
|
+
}
|
|
461
|
+
if (needsGlobalSkillInstall) {
|
|
462
|
+
steps.push("Sync global Agent Skills: featflow skills install");
|
|
463
|
+
}
|
|
369
464
|
if (!options.merge && config.mode === "developer-branch" && !devSetupSummary) {
|
|
370
465
|
steps.push("Run: featflow setup <your-branch-name>");
|
|
371
466
|
}
|
|
@@ -8,8 +8,12 @@ const usage = `
|
|
|
8
8
|
Usage:
|
|
9
9
|
featflow policy <pre-commit|pre-push>
|
|
10
10
|
|
|
11
|
-
Enforces branch protection
|
|
12
|
-
|
|
11
|
+
Enforces branch protection, workflow setup guards, and optional pre-commit
|
|
12
|
+
fileSizeBudget checks (when fileSizeBudget.enforceInPreCommit is enabled).
|
|
13
|
+
|
|
14
|
+
Environment:
|
|
15
|
+
FEATFLOW_BOOTSTRAP=1 Bypass policy checks for one-off repository bootstrap tasks
|
|
16
|
+
FEATFLOW_SKIP_SIZE_CHECK=1 Bypass only the pre-commit fileSizeBudget check once
|
|
13
17
|
`.trim();
|
|
14
18
|
|
|
15
19
|
function readStdin() {
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { loadConfig } from "../config.mjs";
|
|
2
|
+
import { fail, findRepoRoot } from "../git.mjs";
|
|
3
|
+
import {
|
|
4
|
+
BUNDLED_SKILLS,
|
|
5
|
+
inspectSkillsStatus,
|
|
6
|
+
installGlobalSkills,
|
|
7
|
+
parseGlobalSkillAgents,
|
|
8
|
+
parseSkillNamesList,
|
|
9
|
+
uninstallGlobalSkills,
|
|
10
|
+
} from "../skills-manager.mjs";
|
|
11
|
+
|
|
12
|
+
const usage = `
|
|
13
|
+
Usage:
|
|
14
|
+
featflow skills install [options]
|
|
15
|
+
featflow skills status [options]
|
|
16
|
+
featflow skills uninstall [options]
|
|
17
|
+
|
|
18
|
+
Manages global featflow Agent Skills synced directly from the installed
|
|
19
|
+
@danielstyle/featflow package (offline, version-matched with your CLI).
|
|
20
|
+
|
|
21
|
+
Global skill targets (auto-detected by default):
|
|
22
|
+
- ~/.agents/skills/ (Standard: Antigravity, Codex, Cursor)
|
|
23
|
+
- ~/.claude/skills/ (Claude Code, when ~/.claude exists)
|
|
24
|
+
- ~/.codex/skills/ (OpenAI Codex, when ~/.codex exists)
|
|
25
|
+
- ~/.cursor/skills/ (Cursor, when ~/.cursor exists)
|
|
26
|
+
|
|
27
|
+
Options:
|
|
28
|
+
--only <skills> Comma-separated subset: ${BUNDLED_SKILLS.join(",")} (default: all)
|
|
29
|
+
--agents <list> Comma-separated targets: agents,claude-code,codex,cursor,all,auto (default: auto)
|
|
30
|
+
--dry-run Preview changes without writing or deleting files
|
|
31
|
+
--json Output machine-readable JSON
|
|
32
|
+
-h, --help Show this help
|
|
33
|
+
`.trim();
|
|
34
|
+
|
|
35
|
+
function parseArgs(argv) {
|
|
36
|
+
const action = argv[0] ?? "";
|
|
37
|
+
if (!action || action === "-h" || action === "--help") {
|
|
38
|
+
console.log(usage);
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
if (!["install", "sync", "status", "uninstall"].includes(action)) {
|
|
42
|
+
fail(`Unknown skills subcommand "${action}". Expected "install", "status", or "uninstall".`, usage);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const options = {
|
|
46
|
+
action: action === "sync" ? "install" : action,
|
|
47
|
+
skillNames: [...BUNDLED_SKILLS],
|
|
48
|
+
agents: null,
|
|
49
|
+
dryRun: false,
|
|
50
|
+
json: false,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
for (let i = 1; i < argv.length; i += 1) {
|
|
54
|
+
const arg = argv[i];
|
|
55
|
+
if (arg === "-h" || arg === "--help") {
|
|
56
|
+
console.log(usage);
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
if (arg === "--only" || arg.startsWith("--only=")) {
|
|
60
|
+
const value = arg.startsWith("--only=") ? arg.slice("--only=".length) : (argv[++i] ?? "");
|
|
61
|
+
try {
|
|
62
|
+
options.skillNames = parseSkillNamesList(value);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
fail(error instanceof Error ? error.message : String(error), usage);
|
|
65
|
+
}
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (arg === "--agents" || arg.startsWith("--agents=")) {
|
|
69
|
+
const value = arg.startsWith("--agents=") ? arg.slice("--agents=".length) : (argv[++i] ?? "");
|
|
70
|
+
try {
|
|
71
|
+
options.agents = parseGlobalSkillAgents(value);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
fail(error instanceof Error ? error.message : String(error), usage);
|
|
74
|
+
}
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (arg === "--dry-run") {
|
|
78
|
+
options.dryRun = true;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (arg === "--json") {
|
|
82
|
+
options.json = true;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
fail(`Unknown option for skills ${action}: ${arg}`, usage);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return options;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export async function runSkills(argv) {
|
|
92
|
+
const options = parseArgs(argv);
|
|
93
|
+
|
|
94
|
+
if (options.action === "install") {
|
|
95
|
+
const result = installGlobalSkills({
|
|
96
|
+
skillNames: options.skillNames,
|
|
97
|
+
agents: options.agents,
|
|
98
|
+
dryRun: options.dryRun,
|
|
99
|
+
});
|
|
100
|
+
if (options.json) {
|
|
101
|
+
console.log(JSON.stringify(result, null, 2));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const verb = options.dryRun ? "Would install/update" : "Synced";
|
|
105
|
+
if (result.installed.length === 0 && result.updated.length === 0) {
|
|
106
|
+
console.log(
|
|
107
|
+
`All global featflow skills are already up to date (${result.upToDate.length} file(s) across ${result.targets.map((t) => t.displayDir).join(", ")}).`,
|
|
108
|
+
);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
console.log(`${verb} global featflow skills:`);
|
|
112
|
+
for (const item of result.installed) {
|
|
113
|
+
console.log(` + ${item.display}`);
|
|
114
|
+
}
|
|
115
|
+
for (const item of result.updated) {
|
|
116
|
+
console.log(` ~ ${item.display}`);
|
|
117
|
+
}
|
|
118
|
+
if (result.upToDate.length > 0) {
|
|
119
|
+
console.log(` = ${result.upToDate.length} already up to date`);
|
|
120
|
+
}
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (options.action === "uninstall") {
|
|
125
|
+
const result = uninstallGlobalSkills({
|
|
126
|
+
skillNames: options.skillNames,
|
|
127
|
+
agents: options.agents,
|
|
128
|
+
dryRun: options.dryRun,
|
|
129
|
+
});
|
|
130
|
+
if (options.json) {
|
|
131
|
+
console.log(JSON.stringify(result, null, 2));
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (result.removed.length === 0) {
|
|
135
|
+
console.log("No global featflow skills found to remove.");
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const verb = options.dryRun ? "Would remove" : "Removed";
|
|
139
|
+
console.log(`${verb} global featflow skills:`);
|
|
140
|
+
for (const item of result.removed) {
|
|
141
|
+
console.log(` - ${item.display}`);
|
|
142
|
+
}
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const repoRoot = findRepoRoot(process.cwd());
|
|
147
|
+
let repoConfig = null;
|
|
148
|
+
if (repoRoot) {
|
|
149
|
+
try {
|
|
150
|
+
repoConfig = loadConfig(repoRoot).config;
|
|
151
|
+
} catch {
|
|
152
|
+
repoConfig = null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const report = inspectSkillsStatus({
|
|
156
|
+
repoRoot,
|
|
157
|
+
skillNames: options.skillNames,
|
|
158
|
+
agents: options.agents,
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
if (options.json) {
|
|
162
|
+
console.log(JSON.stringify({ ...report, repoRoot, repoMode: repoConfig?.mode ?? null }, null, 2));
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
console.log("featflow skills status");
|
|
167
|
+
console.log(`Global target dirs: ${report.targets.map((t) => t.displayDir).join(", ") || "(none)"}`);
|
|
168
|
+
for (const skill of report.skills) {
|
|
169
|
+
const globalSummary = skill.globalTargets.map((t) => `${t.agentId}=${t.status}`).join(", ");
|
|
170
|
+
const repoNote = skill.hasRepoCopy ? ` | repo=.agents/skills/${skill.name} (${skill.repoStatus})` : "";
|
|
171
|
+
console.log(` - ${skill.name}: ${globalSummary}${repoNote}`);
|
|
172
|
+
}
|
|
173
|
+
if (report.missingSkills.length > 0 || report.driftedSkills.length > 0) {
|
|
174
|
+
console.log("\nRun `featflow skills install` to install or refresh global skills.");
|
|
175
|
+
}
|
|
176
|
+
if (report.shadowedSkills.length > 0) {
|
|
177
|
+
console.log(
|
|
178
|
+
`\nNote: repo-level .agents/skills/ copies exist for [${report.shadowedSkills.join(", ")}] and take precedence over global skills in this repo. Remove them to follow global updates automatically, or run \`featflow sync\` to keep them updated.`,
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
}
|
package/src/commands/sync.mjs
CHANGED
|
@@ -27,6 +27,7 @@ Options:
|
|
|
27
27
|
--check Verify managed files match the installed featflow version (exit 1 on drift).
|
|
28
28
|
--dry-run Print files that would be created or updated without writing.
|
|
29
29
|
--only <groups> Comma-separated subset: skill,issues-skill,regression-skill,templates,githooks,agent-docs.
|
|
30
|
+
--with-repo-skills Include repo-embedded .agents/skills/ files even if not present yet.
|
|
30
31
|
--with-issues-skill Include .agents/skills/featflow-issues/SKILL.md even if issues is not configured yet.
|
|
31
32
|
--skip-issues-skill Skip .agents/skills/featflow-issues/SKILL.md even if issues is configured.
|
|
32
33
|
--with-regression-skill Include .agents/skills/featflow-regression/SKILL.md.
|
|
@@ -44,6 +45,7 @@ function parseArgs(argv) {
|
|
|
44
45
|
check: false,
|
|
45
46
|
dryRun: false,
|
|
46
47
|
only: null,
|
|
48
|
+
withRepoSkills: false,
|
|
47
49
|
withIssuesSkill: false,
|
|
48
50
|
skipIssuesSkill: false,
|
|
49
51
|
withRegressionSkill: false,
|
|
@@ -69,6 +71,10 @@ function parseArgs(argv) {
|
|
|
69
71
|
options.dryRun = true;
|
|
70
72
|
continue;
|
|
71
73
|
}
|
|
74
|
+
if (arg === "--with-repo-skills") {
|
|
75
|
+
options.withRepoSkills = true;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
72
78
|
if (arg === "--with-issues-skill") {
|
|
73
79
|
options.withIssuesSkill = true;
|
|
74
80
|
continue;
|
|
@@ -143,23 +149,31 @@ function resolveGroups(options, repoRoot, config) {
|
|
|
143
149
|
const hasRepoSkill = existsSync(path.join(repoRoot, ".agents", "skills", "featflow", "SKILL.md"));
|
|
144
150
|
const hasIssuesSkill = existsSync(path.join(repoRoot, ".agents", "skills", "featflow-issues", "SKILL.md"));
|
|
145
151
|
const hasRegressionSkill = existsSync(path.join(repoRoot, ".agents", "skills", "featflow-regression", "SKILL.md"));
|
|
146
|
-
const hasRepoTemplates =
|
|
152
|
+
const hasRepoTemplates =
|
|
153
|
+
existsSync(path.join(repoRoot, config.featuresDir, "_template.md")) ||
|
|
154
|
+
existsSync(path.join(repoRoot, config.featuresDir, "README.md")) ||
|
|
155
|
+
existsSync(path.join(repoRoot, config.featuresDir, "_program_template.md"));
|
|
147
156
|
const hasGithooksDir = existsSync(path.join(repoRoot, ".githooks"));
|
|
148
157
|
const managedAgentDocs = findManagedAgentDocs(repoRoot);
|
|
149
|
-
const
|
|
158
|
+
const includeRepoSkills = options.withRepoSkills || hasRepoSkill;
|
|
150
159
|
|
|
151
160
|
const groups = new Set();
|
|
152
|
-
if (
|
|
161
|
+
if (includeRepoSkills) {
|
|
153
162
|
groups.add("skill");
|
|
163
|
+
}
|
|
164
|
+
if (hasRepoTemplates) {
|
|
154
165
|
groups.add("templates");
|
|
155
166
|
}
|
|
156
167
|
if (
|
|
157
168
|
!options.skipIssuesSkill &&
|
|
158
|
-
(options.withIssuesSkill || hasIssuesSkill || (
|
|
169
|
+
(options.withIssuesSkill || hasIssuesSkill || (includeRepoSkills && Boolean(config.issues)))
|
|
159
170
|
) {
|
|
160
171
|
groups.add("issues-skill");
|
|
161
172
|
}
|
|
162
|
-
if (
|
|
173
|
+
if (
|
|
174
|
+
!options.skipRegressionSkill &&
|
|
175
|
+
(options.withRegressionSkill || hasRegressionSkill || (includeRepoSkills && Boolean(config.regression)))
|
|
176
|
+
) {
|
|
163
177
|
groups.add("regression-skill");
|
|
164
178
|
}
|
|
165
179
|
if (!options.skipGithooks && (options.withGithooks || hasGithooksDir)) {
|
package/src/hooks-core.mjs
CHANGED
|
@@ -278,7 +278,7 @@ export function evaluateUserPrompt(config, payload) {
|
|
|
278
278
|
|
|
279
279
|
if (/feature|plan|workflow|worktree|milestone|roadmap|refactor|implement|迁移|重构|计划|工作流|功能|实现/.test(lower)) {
|
|
280
280
|
reminders.push(
|
|
281
|
-
`For substantial or write-oriented work, follow the featflow skill
|
|
281
|
+
`For substantial or write-oriented work, follow the \`featflow\` skill: complete read-only discovery, present a concrete plan, wait for approval, and work in a dedicated worktree (\`featflow worktree\`).`,
|
|
282
282
|
);
|
|
283
283
|
}
|
|
284
284
|
|
|
@@ -300,7 +300,7 @@ export function evaluateUserPrompt(config, payload) {
|
|
|
300
300
|
)
|
|
301
301
|
) {
|
|
302
302
|
reminders.push(
|
|
303
|
-
"For GitHub Issues (filing with prefixes/screenshots or claiming & reviewing), follow
|
|
303
|
+
"For GitHub Issues (filing with prefixes/screenshots or claiming & reviewing), follow the `featflow-issues` skill and use `featflow issue create|list|view|claim|review|release` (do not create an Issue for plain direct fix requests).",
|
|
304
304
|
);
|
|
305
305
|
}
|
|
306
306
|
|
package/src/index.mjs
CHANGED