geloforge 0.7.0 → 0.9.1
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 +109 -31
- package/VERSION +1 -1
- package/core/audit-provider.mjs +91 -22
- package/core/coding-loop.mjs +500 -0
- package/core/compatibility.json +1 -1
- package/core/context-cache.mjs +4 -3
- package/core/context-compiler.mjs +77 -10
- package/core/doctor.mjs +319 -0
- package/core/hooks-init.mjs +245 -0
- package/core/mcp-init.mjs +3 -2
- package/core/mcp-lock.mjs +488 -0
- package/core/mcp-server.mjs +70 -8
- package/core/project-lock.mjs +49 -17
- package/core/project-status.mjs +42 -0
- package/core/skills-advisor.mjs +944 -0
- package/core/text-utils.mjs +63 -5
- package/package.json +11 -2
- package/scripts/geloforge.mjs +420 -7
package/core/text-utils.mjs
CHANGED
|
@@ -24,17 +24,75 @@ export function estimateTokens(text) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* Extracts normalized search
|
|
27
|
+
* Extracts normalized search term tokens (>= 3 chars, excluding stop words), preserving multiplicities.
|
|
28
28
|
*/
|
|
29
|
-
export function
|
|
29
|
+
export function tokenizeTerms(text) {
|
|
30
30
|
if (!text || typeof text !== "string") {
|
|
31
|
-
return
|
|
31
|
+
return [];
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
return text
|
|
34
34
|
.toLowerCase()
|
|
35
35
|
.split(/[^a-z0-9_-]+/)
|
|
36
36
|
.filter((t) => t.length >= 3 && !STOP_WORDS.has(t));
|
|
37
|
-
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Extracts normalized unique search keywords (>= 3 chars, excluding stop words).
|
|
41
|
+
*/
|
|
42
|
+
export function tokenizeKeywords(text) {
|
|
43
|
+
return new Set(tokenizeTerms(text));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Computes deterministic Okapi BM25 scores for candidate term arrays against query terms.
|
|
48
|
+
*/
|
|
49
|
+
export function scoreBm25Documents(queryTerms, docs, { k1 = 1.5, b = 0.75 } = {}) {
|
|
50
|
+
const uniqueQuery = [];
|
|
51
|
+
const seenQuery = new Set();
|
|
52
|
+
for (const term of queryTerms || []) {
|
|
53
|
+
if (typeof term === "string" && term.length > 0 && !seenQuery.has(term)) {
|
|
54
|
+
seenQuery.add(term);
|
|
55
|
+
uniqueQuery.push(term);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const scores = new Map();
|
|
59
|
+
if (uniqueQuery.length === 0 || !Array.isArray(docs) || docs.length === 0) {
|
|
60
|
+
return scores;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const totalDocs = docs.length;
|
|
64
|
+
const docFreq = new Map(uniqueQuery.map((term) => [term, 0]));
|
|
65
|
+
let totalTerms = 0;
|
|
66
|
+
|
|
67
|
+
const docStats = docs.map((doc) => {
|
|
68
|
+
const terms = Array.isArray(doc.terms) ? doc.terms : [];
|
|
69
|
+
totalTerms += terms.length;
|
|
70
|
+
const tf = new Map();
|
|
71
|
+
for (const term of terms) {
|
|
72
|
+
if (docFreq.has(term)) {
|
|
73
|
+
tf.set(term, (tf.get(term) ?? 0) + 1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
for (const term of tf.keys()) {
|
|
77
|
+
docFreq.set(term, (docFreq.get(term) ?? 0) + 1);
|
|
78
|
+
}
|
|
79
|
+
return { id: doc.id, length: terms.length, tf };
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const avgdl = totalTerms > 0 ? totalTerms / totalDocs : 1;
|
|
83
|
+
for (const doc of docStats) {
|
|
84
|
+
let score = 0;
|
|
85
|
+
const normFactor = 1 - b + b * (doc.length / avgdl);
|
|
86
|
+
for (const term of uniqueQuery) {
|
|
87
|
+
const freq = doc.tf.get(term) ?? 0;
|
|
88
|
+
if (freq === 0) continue;
|
|
89
|
+
const df = docFreq.get(term) ?? 0;
|
|
90
|
+
const idf = Math.log(1 + (totalDocs - df + 0.5) / (df + 0.5));
|
|
91
|
+
score += idf * ((freq * (k1 + 1)) / (freq + k1 * normFactor));
|
|
92
|
+
}
|
|
93
|
+
scores.set(doc.id, Math.round(score * 1e6) / 1e6);
|
|
94
|
+
}
|
|
95
|
+
return scores;
|
|
38
96
|
}
|
|
39
97
|
|
|
40
98
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geloforge",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.9.1",
|
|
4
|
+
"description": "Zero-dependency local CLI & MCP server for AI coding agents — shared project memory, verified test evidence, skill advisor, MCP tool pinning, and cross-agent handoffs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -15,10 +15,18 @@
|
|
|
15
15
|
"keywords": [
|
|
16
16
|
"ai-coding",
|
|
17
17
|
"ai-harness",
|
|
18
|
+
"mcp",
|
|
19
|
+
"mcp-server",
|
|
18
20
|
"agent-skills",
|
|
21
|
+
"coding-agent",
|
|
22
|
+
"claude-code",
|
|
23
|
+
"cursor",
|
|
24
|
+
"codex",
|
|
25
|
+
"gemini-cli",
|
|
19
26
|
"context-engineering",
|
|
20
27
|
"project-memory",
|
|
21
28
|
"cross-agent-handoff",
|
|
29
|
+
"zero-dependency",
|
|
22
30
|
"developer-tools"
|
|
23
31
|
],
|
|
24
32
|
"engines": {
|
|
@@ -45,6 +53,7 @@
|
|
|
45
53
|
"bootstrap": "node scripts/bootstrap-project.mjs",
|
|
46
54
|
"geloforge": "node scripts/geloforge.mjs",
|
|
47
55
|
"benchmark": "node scripts/benchmark-context.mjs",
|
|
56
|
+
"eval": "node scripts/run-evals.mjs",
|
|
48
57
|
"smoke:package": "node scripts/smoke-fresh-install.mjs --packed",
|
|
49
58
|
"benchmark:cache": "node scripts/benchmark-context-cache.mjs",
|
|
50
59
|
"benchmark:audits": "node --test tests/staging-audit-worker.test.mjs"
|
package/scripts/geloforge.mjs
CHANGED
|
@@ -36,10 +36,15 @@ import { verifyTask } from "../core/verify-task.mjs";
|
|
|
36
36
|
import { createCheckpoint, getCheckpoint, listCheckpoints } from "../core/checkpoint.mjs";
|
|
37
37
|
import { startMcpStdioServer } from "../core/mcp-server.mjs";
|
|
38
38
|
import { initMcpClients } from "../core/mcp-init.mjs";
|
|
39
|
+
import { checkMcpLock, lockMcpServers } from "../core/mcp-lock.mjs";
|
|
40
|
+
import { runProjectDoctor } from "../core/doctor.mjs";
|
|
41
|
+
import { HOOK_TARGETS, initProjectHooks } from "../core/hooks-init.mjs";
|
|
42
|
+
import { getCodingLoopStatus, runCodingLoop } from "../core/coding-loop.mjs";
|
|
39
43
|
import {
|
|
40
44
|
discoverSkills,
|
|
41
45
|
resolveProjectForSkills,
|
|
42
46
|
} from "../core/skills.mjs";
|
|
47
|
+
import { suggestProjectSkills } from "../core/skills-advisor.mjs";
|
|
43
48
|
import { STATIC_LINT_DISCLAIMER, lintDiscoveredSkills, lintSkill } from "../core/skills-lint.mjs";
|
|
44
49
|
import {
|
|
45
50
|
draftSkillFromExperience,
|
|
@@ -82,10 +87,13 @@ Commands:
|
|
|
82
87
|
checkpoint Create, list, or inspect session recovery checkpoints (CHKPT-NNNN)
|
|
83
88
|
recommend Show ranked Human-in-the-Loop Co-Pilot recommendations & approval inbox
|
|
84
89
|
autonomous Run opt-in staging audits, review progress, and learn from completed audits
|
|
90
|
+
loop Run bounded implement -> verify -> review -> fix coding loop for a task
|
|
85
91
|
proposal Review, sign, or promote a canonical-document proposal
|
|
86
92
|
worktree Add, list, or remove isolated local Git worktrees
|
|
87
93
|
status Inspect project health, operational task state, leases, and Git status
|
|
88
|
-
|
|
94
|
+
doctor Run one-command diagnostics across setup, compatibility, MCP locks, skills, and hooks
|
|
95
|
+
hooks Install or preview opt-in Git pre-commit, Claude Code, and Gemini CLI hooks (hooks init)
|
|
96
|
+
mcp Start stdio MCP server, configure clients (mcp init), or pin tools (mcp lock)
|
|
89
97
|
|
|
90
98
|
Global Options:
|
|
91
99
|
-h, --help Show help (use "geloforge <command> --help" for command options)
|
|
@@ -95,6 +103,38 @@ Global Options:
|
|
|
95
103
|
|
|
96
104
|
function printSubHelp(cmd) {
|
|
97
105
|
switch (cmd) {
|
|
106
|
+
case "doctor":
|
|
107
|
+
console.log(`Usage: geloforge doctor [options]
|
|
108
|
+
|
|
109
|
+
Checks Node.js runtime, Second Brain validation, harness compatibility, Git status,
|
|
110
|
+
cooperative task leases, skill lint health, MCP tool lockfiles, and ambient hooks.
|
|
111
|
+
|
|
112
|
+
Options:
|
|
113
|
+
-p, --project <path> Target project directory (auto-detected from CWD if omitted)
|
|
114
|
+
--global-dir <path> Override global skills directory (default: GELOFORGE_SKILLS_DIR or ~/.geloforge/skills)
|
|
115
|
+
--include-drafts Include quarantined drafts when running skills lint
|
|
116
|
+
--skip-mcp-check Skip probing stdio MCP servers when .geloforge/mcp-lock.json exists
|
|
117
|
+
--timeout-ms <ms> MCP probe timeout in ms (500-30000)
|
|
118
|
+
--json Emit structured JSON output
|
|
119
|
+
-h, --help Show help
|
|
120
|
+
`);
|
|
121
|
+
break;
|
|
122
|
+
case "hooks":
|
|
123
|
+
console.log(`Usage: geloforge hooks init [options]
|
|
124
|
+
|
|
125
|
+
Installs or previews lightweight, opt-in local checks without background daemons:
|
|
126
|
+
git .git/hooks/pre-commit (runs geloforge validate + mcp lock --check if locked)
|
|
127
|
+
claude .claude/settings.json hooks.Stop (advisory doctor reminder)
|
|
128
|
+
gemini .gemini/settings.json hooks.AfterAgent (preserves existing mcpServers)
|
|
129
|
+
|
|
130
|
+
Options:
|
|
131
|
+
-p, --project <path> Target project directory (auto-detected from CWD if omitted)
|
|
132
|
+
--target <list> Targets: git, claude, gemini (comma-separated or repeatable; default: all)
|
|
133
|
+
--dry-run Preview file changes without writing disk
|
|
134
|
+
--json Emit structured JSON output
|
|
135
|
+
-h, --help Show help
|
|
136
|
+
`);
|
|
137
|
+
break;
|
|
98
138
|
case "autonomous":
|
|
99
139
|
console.log(`Usage: geloforge autonomous <status|on|off|audit|authorize|watch|progress|learn> [options]
|
|
100
140
|
|
|
@@ -250,6 +290,7 @@ Options:
|
|
|
250
290
|
case "mcp":
|
|
251
291
|
console.log(`Usage: geloforge mcp [serve] [--project <path>] [--read-only]
|
|
252
292
|
geloforge mcp init [--project <path>] [--client <name>] [--read-only] [--dry-run] [--json]
|
|
293
|
+
geloforge mcp lock [--project <path>] [--client <name>] [--check] [--dry-run] [--timeout-ms <ms>] [--json]
|
|
253
294
|
|
|
254
295
|
Runs GeloForge's zero-dependency JSON-RPC 2.0 MCP server on stdin/stdout.
|
|
255
296
|
Pins operations to the configured/current project root (when present).
|
|
@@ -263,10 +304,30 @@ Options:
|
|
|
263
304
|
--read-only Refuse all state-mutating MCP actions
|
|
264
305
|
-h, --help Show help
|
|
265
306
|
|
|
266
|
-
Init options:
|
|
267
|
-
--client <name> cursor, vscode, claude, gemini, or antigravity
|
|
268
|
-
--
|
|
269
|
-
--
|
|
307
|
+
Init / Lock options:
|
|
308
|
+
--client <name> cursor, vscode, claude, gemini, or antigravity
|
|
309
|
+
--check Compare live stdio MCP tool definitions against .geloforge/mcp-lock.json
|
|
310
|
+
--timeout-ms <ms> Probe timeout per stdio server (100-60000, default: 8000)
|
|
311
|
+
--dry-run Preview changes without writing files
|
|
312
|
+
--json Emit structured JSON output
|
|
313
|
+
`);
|
|
314
|
+
break;
|
|
315
|
+
case "loop":
|
|
316
|
+
console.log(`Usage: geloforge loop run --config <relpath> [--task TASK-NNNN] [options]
|
|
317
|
+
geloforge loop status [--task TASK-NNNN] [--project <path>] [--json]
|
|
318
|
+
|
|
319
|
+
Run a bounded implement -> verify -> review -> fix loop for one open task.
|
|
320
|
+
Deterministic command verification gates task completion; LLM review never overrides a failing gate.
|
|
321
|
+
|
|
322
|
+
Options:
|
|
323
|
+
-p, --project <path> Target project directory (auto-detected from CWD if omitted)
|
|
324
|
+
--config <relpath> Project-relative JSON config file (required for 'run')
|
|
325
|
+
-t, --task <TASK-NNNN> Target task ID (defaults to sole active task)
|
|
326
|
+
--tool <name> Cooperative lease tool label
|
|
327
|
+
--session <id> Cooperative lease session label
|
|
328
|
+
--dry-run Validate config, executables, task, and context without running providers
|
|
329
|
+
--json Emit structured JSON output
|
|
330
|
+
-h, --help Show help
|
|
270
331
|
`);
|
|
271
332
|
break;
|
|
272
333
|
case "handoff":
|
|
@@ -395,11 +456,12 @@ Safety & Accuracy Notes:
|
|
|
395
456
|
case "skills":
|
|
396
457
|
console.log(`Usage: geloforge skills <subcommand> [options]
|
|
397
458
|
|
|
398
|
-
Discovery
|
|
459
|
+
Discovery, Static Checks & Advisor:
|
|
399
460
|
list List discovered portable skills across project (.agents/skills) and global dirs
|
|
400
461
|
show Inspect one skill's metadata, supporting resources, and instructions
|
|
401
462
|
validate Validate SKILL.md frontmatter, path/symlink/secret safety, and local links
|
|
402
463
|
lint Run static security and quality lint checks across discovered skills
|
|
464
|
+
suggest Analyze project signals & goal to rank existing skills, detect gaps, or scaffold drafts
|
|
403
465
|
|
|
404
466
|
Adaptive Skills Lifecycle (Evidence-Backed & Human-Authorized):
|
|
405
467
|
draft Draft a quarantined skill in proposals/skills/ from verified EVID/HANDOFF records
|
|
@@ -410,6 +472,14 @@ Adaptive Skills Lifecycle (Evidence-Backed & Human-Authorized):
|
|
|
410
472
|
history Inspect append-only revision ledger and snapshot integrity for a skill
|
|
411
473
|
rollback Restore an authorized verified snapshot revision (never bypasses approval)
|
|
412
474
|
|
|
475
|
+
Advisor Options ('suggest'):
|
|
476
|
+
--goal <text> Target goal description to rank existing skills and detect gaps
|
|
477
|
+
--query <text> Alias for --goal
|
|
478
|
+
--task <TASK-NNNN> Analyze a specific task's scope and acceptance criteria
|
|
479
|
+
--limit <1..20> Max existing skills to recommend (default: 5)
|
|
480
|
+
--scaffold-draft Stage a quarantined SKILL.md draft under proposals/skills/ (never active)
|
|
481
|
+
--name <skill-slug> Custom skill slug when used with --scaffold-draft
|
|
482
|
+
|
|
413
483
|
Authorization Options for 'promote' & 'rollback':
|
|
414
484
|
--approval <APPR-NNNN> Verify cryptographic Ed25519 signature (recommended)
|
|
415
485
|
--public-key <file> Verify signature against an external pinned SPKI public key PEM
|
|
@@ -1109,8 +1179,117 @@ function handleMcpInit(args) {
|
|
|
1109
1179
|
return 0;
|
|
1110
1180
|
}
|
|
1111
1181
|
|
|
1182
|
+
async function handleMcpLock(args) {
|
|
1183
|
+
const { values } = parseArgs({
|
|
1184
|
+
args,
|
|
1185
|
+
options: {
|
|
1186
|
+
project: { type: "string", short: "p" },
|
|
1187
|
+
client: { type: "string", multiple: true },
|
|
1188
|
+
check: { type: "boolean", default: false },
|
|
1189
|
+
"dry-run": { type: "boolean", default: false },
|
|
1190
|
+
"timeout-ms": { type: "string" },
|
|
1191
|
+
json: { type: "boolean", default: false },
|
|
1192
|
+
help: { type: "boolean", short: "h", default: false },
|
|
1193
|
+
},
|
|
1194
|
+
strict: true,
|
|
1195
|
+
allowPositionals: false,
|
|
1196
|
+
});
|
|
1197
|
+
if (values.help) {
|
|
1198
|
+
printSubHelp("mcp");
|
|
1199
|
+
return 0;
|
|
1200
|
+
}
|
|
1201
|
+
if (values.check && values["dry-run"]) {
|
|
1202
|
+
throw new Error("--dry-run only applies when writing .geloforge/mcp-lock.json.");
|
|
1203
|
+
}
|
|
1204
|
+
const timeoutMs = values["timeout-ms"] !== undefined ? parseCheckTimeout(values["timeout-ms"]) : undefined;
|
|
1205
|
+
const { projectDir } = resolveProjectDir({ project: values.project, harnessDir: HARNESS_DIR });
|
|
1206
|
+
const result = values.check
|
|
1207
|
+
? await checkMcpLock({ projectDir, harnessDir: HARNESS_DIR, clients: values.client, timeoutMs })
|
|
1208
|
+
: await lockMcpServers({
|
|
1209
|
+
projectDir,
|
|
1210
|
+
harnessDir: HARNESS_DIR,
|
|
1211
|
+
clients: values.client,
|
|
1212
|
+
timeoutMs,
|
|
1213
|
+
dryRun: values["dry-run"],
|
|
1214
|
+
});
|
|
1215
|
+
if (values.json) {
|
|
1216
|
+
console.log(JSON.stringify(result, null, 2));
|
|
1217
|
+
} else if (values.check) {
|
|
1218
|
+
console.log(
|
|
1219
|
+
result.passed
|
|
1220
|
+
? `MCP lock verified (${result.checkedCount} stdio server(s)): ${result.lockPath}`
|
|
1221
|
+
: `MCP lock check failed (${result.driftedServers.length} drifted, ${result.addedServers.length} added, ${result.removedServers.length} removed, ${result.errors.length} errors)`
|
|
1222
|
+
);
|
|
1223
|
+
} else {
|
|
1224
|
+
console.log(
|
|
1225
|
+
`${result.dryRun ? "DRY RUN — " : ""}Pinned ${result.serverCount} stdio MCP server(s) to ${result.lockPath} (${result.skippedCount} non-stdio skipped)`
|
|
1226
|
+
);
|
|
1227
|
+
}
|
|
1228
|
+
return values.check && !result.passed ? 1 : 0;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
async function handleLoop(args) {
|
|
1232
|
+
if (!args.length || args[0] === "-h" || args[0] === "--help") {
|
|
1233
|
+
printSubHelp("loop");
|
|
1234
|
+
return 0;
|
|
1235
|
+
}
|
|
1236
|
+
const [subcmd, ...rest] = args;
|
|
1237
|
+
if (!["run", "status"].includes(subcmd)) {
|
|
1238
|
+
throw new Error(`Unknown loop subcommand "${subcmd}". Expected: run or status.`);
|
|
1239
|
+
}
|
|
1240
|
+
const { values } = parseArgs({
|
|
1241
|
+
args: rest,
|
|
1242
|
+
options: {
|
|
1243
|
+
project: { type: "string", short: "p" },
|
|
1244
|
+
config: { type: "string" },
|
|
1245
|
+
task: { type: "string", short: "t" },
|
|
1246
|
+
tool: { type: "string" },
|
|
1247
|
+
session: { type: "string" },
|
|
1248
|
+
"dry-run": { type: "boolean", default: false },
|
|
1249
|
+
json: { type: "boolean", default: false },
|
|
1250
|
+
help: { type: "boolean", short: "h", default: false },
|
|
1251
|
+
},
|
|
1252
|
+
strict: true,
|
|
1253
|
+
allowPositionals: false,
|
|
1254
|
+
});
|
|
1255
|
+
if (values.help) {
|
|
1256
|
+
printSubHelp("loop");
|
|
1257
|
+
return 0;
|
|
1258
|
+
}
|
|
1259
|
+
const { projectDir } = resolveProjectDir({ project: values.project, harnessDir: HARNESS_DIR });
|
|
1260
|
+
if (subcmd === "status") {
|
|
1261
|
+
const res = getCodingLoopStatus({ projectDir, harnessDir: HARNESS_DIR, taskId: values.task });
|
|
1262
|
+
if (values.json) console.log(JSON.stringify(res, null, 2));
|
|
1263
|
+
else console.log(`${res.taskId} loop status: ${res.status} (rounds=${res.roundsUsed}/${res.maxFixRounds}, attempts=${res.implementAttempts})`);
|
|
1264
|
+
return 0;
|
|
1265
|
+
}
|
|
1266
|
+
if (!values.config) {
|
|
1267
|
+
throw new Error("Missing required --config <relpath> for 'geloforge loop run'.");
|
|
1268
|
+
}
|
|
1269
|
+
const res = await runCodingLoop({
|
|
1270
|
+
projectDir,
|
|
1271
|
+
harnessDir: HARNESS_DIR,
|
|
1272
|
+
configFile: values.config,
|
|
1273
|
+
taskId: values.task,
|
|
1274
|
+
tool: values.tool,
|
|
1275
|
+
sessionId: values.session,
|
|
1276
|
+
dryRun: values["dry-run"],
|
|
1277
|
+
});
|
|
1278
|
+
if (values.json) {
|
|
1279
|
+
console.log(JSON.stringify(res, null, 2));
|
|
1280
|
+
} else if (res.status === "dry_run") {
|
|
1281
|
+
console.log(`DRY RUN — Loop ready for ${res.taskId} (maxFixRounds=${res.maxFixRounds}, verify=${res.verifyCommand.join(" ")})`);
|
|
1282
|
+
} else if (res.status === "completed") {
|
|
1283
|
+
console.log(`${res.taskId} completed (${res.evidenceId}, ${res.checkpointId}) in ${res.roundsUsed} fix round(s)`);
|
|
1284
|
+
} else {
|
|
1285
|
+
console.error(`${res.taskId} blocked (${res.reason}, ${res.checkpointId})`);
|
|
1286
|
+
}
|
|
1287
|
+
return ["completed", "dry_run"].includes(res.status) ? 0 : 1;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1112
1290
|
async function handleMcp(args) {
|
|
1113
1291
|
if (args[0] === "init") return handleMcpInit(args.slice(1));
|
|
1292
|
+
if (args[0] === "lock") return handleMcpLock(args.slice(1));
|
|
1114
1293
|
let effectiveArgs = args;
|
|
1115
1294
|
if (args.length > 0 && (args[0] === "-h" || args[0] === "--help")) {
|
|
1116
1295
|
printSubHelp("mcp");
|
|
@@ -2215,6 +2394,128 @@ async function handleSkillsLifecycle(subcmd, rest) {
|
|
|
2215
2394
|
throw new Error(`Unknown skills subcommand "${subcmd}".`);
|
|
2216
2395
|
}
|
|
2217
2396
|
|
|
2397
|
+
async function handleSkillsSuggest(rest) {
|
|
2398
|
+
const parsed = parseArgs({
|
|
2399
|
+
args: rest,
|
|
2400
|
+
options: {
|
|
2401
|
+
project: { type: "string", short: "p" },
|
|
2402
|
+
task: { type: "string" },
|
|
2403
|
+
goal: { type: "string" },
|
|
2404
|
+
query: { type: "string" },
|
|
2405
|
+
"global-dir": { type: "string" },
|
|
2406
|
+
"include-drafts": { type: "boolean", default: false },
|
|
2407
|
+
limit: { type: "string" },
|
|
2408
|
+
"scaffold-draft": { type: "boolean", default: false },
|
|
2409
|
+
name: { type: "string" },
|
|
2410
|
+
"dry-run": { type: "boolean", default: false },
|
|
2411
|
+
"created-at": { type: "string" },
|
|
2412
|
+
json: { type: "boolean", default: false },
|
|
2413
|
+
help: { type: "boolean", short: "h", default: false },
|
|
2414
|
+
},
|
|
2415
|
+
strict: true,
|
|
2416
|
+
allowPositionals: false,
|
|
2417
|
+
});
|
|
2418
|
+
if (parsed.values.help) {
|
|
2419
|
+
printSubHelp("skills");
|
|
2420
|
+
return 0;
|
|
2421
|
+
}
|
|
2422
|
+
let limit;
|
|
2423
|
+
if (parsed.values.limit !== undefined) {
|
|
2424
|
+
if (!/^\d+$/.test(parsed.values.limit.trim())) {
|
|
2425
|
+
throw new Error("--limit must be a positive integer (1..20).");
|
|
2426
|
+
}
|
|
2427
|
+
limit = Number(parsed.values.limit.trim());
|
|
2428
|
+
}
|
|
2429
|
+
const scaffoldDraft = Boolean(parsed.values["scaffold-draft"]);
|
|
2430
|
+
if (parsed.values.name && !scaffoldDraft) {
|
|
2431
|
+
throw new Error("--name is only supported with '--scaffold-draft' on 'geloforge skills suggest'.");
|
|
2432
|
+
}
|
|
2433
|
+
if (parsed.values["dry-run"] && !scaffoldDraft) {
|
|
2434
|
+
throw new Error("--dry-run is only supported with '--scaffold-draft' on 'geloforge skills suggest'.");
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
const loc = resolveProjectForSkills({
|
|
2438
|
+
project: parsed.values.project,
|
|
2439
|
+
harnessDir: HARNESS_DIR,
|
|
2440
|
+
});
|
|
2441
|
+
if (!loc.projectDir) {
|
|
2442
|
+
throw new Error("'geloforge skills suggest' requires a GeloForge project directory (--project <path> or inside a project).");
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
const res = suggestProjectSkills({
|
|
2446
|
+
projectDir: loc.projectDir,
|
|
2447
|
+
harnessDir: HARNESS_DIR,
|
|
2448
|
+
globalSkillsDir: parsed.values["global-dir"],
|
|
2449
|
+
taskId: parsed.values.task || null,
|
|
2450
|
+
goal: parsed.values.goal || null,
|
|
2451
|
+
query: parsed.values.query || null,
|
|
2452
|
+
includeDrafts: Boolean(parsed.values["include-drafts"]),
|
|
2453
|
+
limit,
|
|
2454
|
+
scaffoldDraft,
|
|
2455
|
+
skillName: parsed.values.name || null,
|
|
2456
|
+
dryRun: Boolean(parsed.values["dry-run"]),
|
|
2457
|
+
createdAt: parsed.values["created-at"],
|
|
2458
|
+
});
|
|
2459
|
+
|
|
2460
|
+
if (parsed.values.json) {
|
|
2461
|
+
console.log(JSON.stringify(res, null, 2));
|
|
2462
|
+
return 0;
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
console.log(`Skills Advisor : ${res.projectDir} (${res.projectId || "project"})`);
|
|
2466
|
+
if (res.goal) console.log(`Goal : ${res.goal}`);
|
|
2467
|
+
if (res.taskId) console.log(`Task : ${res.taskId}`);
|
|
2468
|
+
console.log(`Detected Stack : ${res.detectedSignals.stacks.join(", ") || "(none)"}`);
|
|
2469
|
+
console.log(
|
|
2470
|
+
`Repo Commands : ${res.detectedSignals.commands.map((c) => c.command).join(" | ") || "(none detected)"}`
|
|
2471
|
+
);
|
|
2472
|
+
console.log(
|
|
2473
|
+
`Skill Pool : ${res.activeSkillCount} active | ${res.quarantinedDraftCount} quarantined draft(s) | ${res.detectedSignals.verifiedEvidenceIds.length} verified EVID-*`
|
|
2474
|
+
);
|
|
2475
|
+
console.log("");
|
|
2476
|
+
console.log("Recommended Existing Skills:");
|
|
2477
|
+
if (res.recommendedSkills.length === 0) {
|
|
2478
|
+
console.log(" (no matching active skills discovered for this project/goal)");
|
|
2479
|
+
} else {
|
|
2480
|
+
for (const item of res.recommendedSkills) {
|
|
2481
|
+
console.log(` - ${item.name} [${item.source}, score=${item.score}] — ${item.reasons.join("; ")}`);
|
|
2482
|
+
console.log(` Use: ${item.command}`);
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
console.log("");
|
|
2486
|
+
console.log("Detected Skill Gaps:");
|
|
2487
|
+
if (res.skillGaps.length === 0) {
|
|
2488
|
+
console.log(" (none detected)");
|
|
2489
|
+
} else {
|
|
2490
|
+
for (const gap of res.skillGaps) {
|
|
2491
|
+
const draftTag = gap.existingQuarantinedDraft ? " [quarantined draft exists]" : "";
|
|
2492
|
+
const promoTag = gap.promotableAfterReview
|
|
2493
|
+
? "evidence-backed (promotable after review)"
|
|
2494
|
+
: "repo/goal scaffold (needs EVID-* before promotion)";
|
|
2495
|
+
console.log(` - [${gap.kind}] ${gap.suggestedName}${draftTag} — ${promoTag}`);
|
|
2496
|
+
console.log(` Reason : ${gap.reason}`);
|
|
2497
|
+
console.log(` Action : ${gap.recommendedCommand}`);
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
if (res.scaffoldResult) {
|
|
2501
|
+
const sr = res.scaffoldResult;
|
|
2502
|
+
console.log("");
|
|
2503
|
+
console.log(
|
|
2504
|
+
sr.dryRun
|
|
2505
|
+
? `DRY RUN — Quarantined scaffold "${sr.skillName}" (${sr.mode}) not written.`
|
|
2506
|
+
: `Quarantined draft created (${sr.mode}): ${sr.proposalDir}/SKILL.md`
|
|
2507
|
+
);
|
|
2508
|
+
console.log(`Candidate SHA : ${sr.candidateDigest}`);
|
|
2509
|
+
console.log(
|
|
2510
|
+
`Promotable Now : ${sr.promotable ? "yes (after human approval/signature)" : "no (capture verified EVID-* first)"}`
|
|
2511
|
+
);
|
|
2512
|
+
for (const step of sr.nextSteps || []) {
|
|
2513
|
+
console.log(` - Next: ${step}`);
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
return 0;
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2218
2519
|
async function handleSkills(args) {
|
|
2219
2520
|
if (args.length === 0 || args[0] === "-h" || args[0] === "--help") {
|
|
2220
2521
|
printSubHelp("skills");
|
|
@@ -2224,9 +2525,12 @@ async function handleSkills(args) {
|
|
|
2224
2525
|
if (["draft", "propose-update", "keygen", "sign", "promote", "history", "rollback"].includes(subcmd)) {
|
|
2225
2526
|
return handleSkillsLifecycle(subcmd, rest);
|
|
2226
2527
|
}
|
|
2528
|
+
if (subcmd === "suggest") {
|
|
2529
|
+
return handleSkillsSuggest(rest);
|
|
2530
|
+
}
|
|
2227
2531
|
if (!["list", "show", "validate", "lint"].includes(subcmd)) {
|
|
2228
2532
|
throw new Error(
|
|
2229
|
-
`Unknown skills subcommand "${subcmd}". Expected: list, show, validate, lint, draft, propose-update, keygen, sign, promote, history, or rollback.`
|
|
2533
|
+
`Unknown skills subcommand "${subcmd}". Expected: list, show, validate, lint, suggest, draft, propose-update, keygen, sign, promote, history, or rollback.`
|
|
2230
2534
|
);
|
|
2231
2535
|
}
|
|
2232
2536
|
|
|
@@ -2429,6 +2733,106 @@ async function handleSkills(args) {
|
|
|
2429
2733
|
return report.passed ? 0 : 1;
|
|
2430
2734
|
}
|
|
2431
2735
|
|
|
2736
|
+
async function handleDoctor(args) {
|
|
2737
|
+
const { values } = parseArgs({
|
|
2738
|
+
args,
|
|
2739
|
+
options: {
|
|
2740
|
+
project: { type: "string", short: "p" },
|
|
2741
|
+
"global-dir": { type: "string" },
|
|
2742
|
+
"include-drafts": { type: "boolean", default: false },
|
|
2743
|
+
"skip-mcp-check": { type: "boolean", default: false },
|
|
2744
|
+
"timeout-ms": { type: "string" },
|
|
2745
|
+
json: { type: "boolean", default: false },
|
|
2746
|
+
help: { type: "boolean", short: "h", default: false },
|
|
2747
|
+
},
|
|
2748
|
+
strict: true,
|
|
2749
|
+
allowPositionals: false,
|
|
2750
|
+
});
|
|
2751
|
+
if (values.help) {
|
|
2752
|
+
printSubHelp("doctor");
|
|
2753
|
+
return 0;
|
|
2754
|
+
}
|
|
2755
|
+
const timeoutMs = values["timeout-ms"] !== undefined ? parseCheckTimeout(values["timeout-ms"]) : undefined;
|
|
2756
|
+
const { projectDir } = resolveProjectDir({ project: values.project, harnessDir: HARNESS_DIR });
|
|
2757
|
+
const res = await runProjectDoctor({
|
|
2758
|
+
projectDir,
|
|
2759
|
+
harnessDir: HARNESS_DIR,
|
|
2760
|
+
globalSkillsDir: values["global-dir"],
|
|
2761
|
+
includeDrafts: values["include-drafts"],
|
|
2762
|
+
checkMcp: !values["skip-mcp-check"],
|
|
2763
|
+
timeoutMs,
|
|
2764
|
+
});
|
|
2765
|
+
if (values.json) {
|
|
2766
|
+
console.log(JSON.stringify(res, null, 2));
|
|
2767
|
+
return res.healthy ? 0 : 1;
|
|
2768
|
+
}
|
|
2769
|
+
console.log(`GeloForge Doctor : ${res.projectDir} (${res.projectId || "project"}) | harness v${res.harnessVersion}`);
|
|
2770
|
+
console.log(`Health Status : ${res.healthy ? "HEALTHY" : "ISSUES FOUND"} (pass=${res.counts.pass} | warn=${res.counts.warn} | fail=${res.counts.fail})`);
|
|
2771
|
+
console.log("");
|
|
2772
|
+
for (const chk of res.checks) {
|
|
2773
|
+
const tag = chk.status === "pass" ? "[PASS]" : chk.status === "warn" ? "[WARN]" : "[FAIL]";
|
|
2774
|
+
console.log(` ${tag} ${chk.id}: ${chk.summary}`);
|
|
2775
|
+
for (const d of chk.details || []) {
|
|
2776
|
+
console.log(` - ${d}`);
|
|
2777
|
+
}
|
|
2778
|
+
if (chk.fix) {
|
|
2779
|
+
console.log(` Fix: ${chk.fix}`);
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2782
|
+
if (res.nextActions.length > 0) {
|
|
2783
|
+
console.log("");
|
|
2784
|
+
console.log("Recommended Next Actions:");
|
|
2785
|
+
for (const cmd of res.nextActions) {
|
|
2786
|
+
console.log(` - ${cmd}`);
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
return res.healthy ? 0 : 1;
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
function handleHooks(args) {
|
|
2793
|
+
if (args.length === 0 || args[0] === "-h" || args[0] === "--help") {
|
|
2794
|
+
printSubHelp("hooks");
|
|
2795
|
+
return 0;
|
|
2796
|
+
}
|
|
2797
|
+
const [subcmd, ...rest] = args;
|
|
2798
|
+
if (subcmd !== "init") {
|
|
2799
|
+
throw new Error(`Unknown hooks subcommand "${subcmd}". Expected: init.`);
|
|
2800
|
+
}
|
|
2801
|
+
const { values } = parseArgs({
|
|
2802
|
+
args: rest,
|
|
2803
|
+
options: {
|
|
2804
|
+
project: { type: "string", short: "p" },
|
|
2805
|
+
target: { type: "string", multiple: true },
|
|
2806
|
+
"dry-run": { type: "boolean", default: false },
|
|
2807
|
+
json: { type: "boolean", default: false },
|
|
2808
|
+
help: { type: "boolean", short: "h", default: false },
|
|
2809
|
+
},
|
|
2810
|
+
strict: true,
|
|
2811
|
+
allowPositionals: false,
|
|
2812
|
+
});
|
|
2813
|
+
if (values.help) {
|
|
2814
|
+
printSubHelp("hooks");
|
|
2815
|
+
return 0;
|
|
2816
|
+
}
|
|
2817
|
+
const { projectDir } = resolveProjectDir({ project: values.project, harnessDir: HARNESS_DIR });
|
|
2818
|
+
const res = initProjectHooks({
|
|
2819
|
+
projectDir,
|
|
2820
|
+
harnessDir: HARNESS_DIR,
|
|
2821
|
+
targets: values.target?.length ? values.target : HOOK_TARGETS,
|
|
2822
|
+
dryRun: values["dry-run"],
|
|
2823
|
+
});
|
|
2824
|
+
if (values.json) {
|
|
2825
|
+
console.log(JSON.stringify(res, null, 2));
|
|
2826
|
+
return 0;
|
|
2827
|
+
}
|
|
2828
|
+
console.log(res.dryRun ? `Hooks setup preview for ${res.projectDir}` : `Hooks setup for ${res.projectDir}`);
|
|
2829
|
+
for (const file of res.files) {
|
|
2830
|
+
const extra = file.reason ? ` (${file.reason})` : "";
|
|
2831
|
+
console.log(` ${file.target.padEnd(7)} ${file.action.padEnd(10)} ${file.path}${extra}`);
|
|
2832
|
+
}
|
|
2833
|
+
return 0;
|
|
2834
|
+
}
|
|
2835
|
+
|
|
2432
2836
|
async function main() {
|
|
2433
2837
|
const argv = process.argv.slice(2);
|
|
2434
2838
|
if (argv.length === 0 || argv[0] === "-h" || argv[0] === "--help") {
|
|
@@ -2477,9 +2881,18 @@ async function main() {
|
|
|
2477
2881
|
case "recommend":
|
|
2478
2882
|
code = handleRecommend(rest);
|
|
2479
2883
|
break;
|
|
2884
|
+
case "doctor":
|
|
2885
|
+
code = await handleDoctor(rest);
|
|
2886
|
+
break;
|
|
2887
|
+
case "hooks":
|
|
2888
|
+
code = handleHooks(rest);
|
|
2889
|
+
break;
|
|
2480
2890
|
case "autonomous":
|
|
2481
2891
|
code = await handleAutonomous(rest);
|
|
2482
2892
|
break;
|
|
2893
|
+
case "loop":
|
|
2894
|
+
code = await handleLoop(rest);
|
|
2895
|
+
break;
|
|
2483
2896
|
case "proposal":
|
|
2484
2897
|
code = handleProposal(rest);
|
|
2485
2898
|
break;
|