preflight-dev 3.1.0
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 +172 -0
- package/bin/cli.js +11 -0
- package/dist/cli/init.d.ts +2 -0
- package/dist/cli/init.js +154 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +122 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/config.d.ts +34 -0
- package/dist/lib/config.js +118 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/embeddings.d.ts +11 -0
- package/dist/lib/embeddings.js +88 -0
- package/dist/lib/embeddings.js.map +1 -0
- package/dist/lib/files.d.ts +15 -0
- package/dist/lib/files.js +60 -0
- package/dist/lib/files.js.map +1 -0
- package/dist/lib/git-extractor.d.ts +9 -0
- package/dist/lib/git-extractor.js +116 -0
- package/dist/lib/git-extractor.js.map +1 -0
- package/dist/lib/git.d.ts +29 -0
- package/dist/lib/git.js +86 -0
- package/dist/lib/git.js.map +1 -0
- package/dist/lib/session-parser.d.ts +45 -0
- package/dist/lib/session-parser.js +267 -0
- package/dist/lib/session-parser.js.map +1 -0
- package/dist/lib/state.d.ts +21 -0
- package/dist/lib/state.js +86 -0
- package/dist/lib/state.js.map +1 -0
- package/dist/lib/timeline-db.d.ts +67 -0
- package/dist/lib/timeline-db.js +380 -0
- package/dist/lib/timeline-db.js.map +1 -0
- package/dist/lib/triage.d.ts +29 -0
- package/dist/lib/triage.js +193 -0
- package/dist/lib/triage.js.map +1 -0
- package/dist/profiles.d.ts +3 -0
- package/dist/profiles.js +65 -0
- package/dist/profiles.js.map +1 -0
- package/dist/tools/audit-workspace.d.ts +2 -0
- package/dist/tools/audit-workspace.js +86 -0
- package/dist/tools/audit-workspace.js.map +1 -0
- package/dist/tools/checkpoint.d.ts +2 -0
- package/dist/tools/checkpoint.js +108 -0
- package/dist/tools/checkpoint.js.map +1 -0
- package/dist/tools/clarify-intent.d.ts +2 -0
- package/dist/tools/clarify-intent.js +180 -0
- package/dist/tools/clarify-intent.js.map +1 -0
- package/dist/tools/enrich-agent-task.d.ts +2 -0
- package/dist/tools/enrich-agent-task.js +97 -0
- package/dist/tools/enrich-agent-task.js.map +1 -0
- package/dist/tools/generate-scorecard.d.ts +2 -0
- package/dist/tools/generate-scorecard.js +617 -0
- package/dist/tools/generate-scorecard.js.map +1 -0
- package/dist/tools/log-correction.d.ts +2 -0
- package/dist/tools/log-correction.js +76 -0
- package/dist/tools/log-correction.js.map +1 -0
- package/dist/tools/onboard-project.d.ts +2 -0
- package/dist/tools/onboard-project.js +179 -0
- package/dist/tools/onboard-project.js.map +1 -0
- package/dist/tools/preflight-check.d.ts +2 -0
- package/dist/tools/preflight-check.js +229 -0
- package/dist/tools/preflight-check.js.map +1 -0
- package/dist/tools/prompt-score.d.ts +2 -0
- package/dist/tools/prompt-score.js +132 -0
- package/dist/tools/prompt-score.js.map +1 -0
- package/dist/tools/scan-sessions.d.ts +2 -0
- package/dist/tools/scan-sessions.js +182 -0
- package/dist/tools/scan-sessions.js.map +1 -0
- package/dist/tools/scope-work.d.ts +2 -0
- package/dist/tools/scope-work.js +214 -0
- package/dist/tools/scope-work.js.map +1 -0
- package/dist/tools/search-history.d.ts +2 -0
- package/dist/tools/search-history.js +130 -0
- package/dist/tools/search-history.js.map +1 -0
- package/dist/tools/sequence-tasks.d.ts +2 -0
- package/dist/tools/sequence-tasks.js +165 -0
- package/dist/tools/sequence-tasks.js.map +1 -0
- package/dist/tools/session-handoff.d.ts +2 -0
- package/dist/tools/session-handoff.js +113 -0
- package/dist/tools/session-handoff.js.map +1 -0
- package/dist/tools/session-health.d.ts +2 -0
- package/dist/tools/session-health.js +111 -0
- package/dist/tools/session-health.js.map +1 -0
- package/dist/tools/session-stats.d.ts +2 -0
- package/dist/tools/session-stats.js +112 -0
- package/dist/tools/session-stats.js.map +1 -0
- package/dist/tools/sharpen-followup.d.ts +2 -0
- package/dist/tools/sharpen-followup.js +192 -0
- package/dist/tools/sharpen-followup.js.map +1 -0
- package/dist/tools/timeline-view.d.ts +2 -0
- package/dist/tools/timeline-view.js +165 -0
- package/dist/tools/timeline-view.js.map +1 -0
- package/dist/tools/token-audit.d.ts +2 -0
- package/dist/tools/token-audit.js +227 -0
- package/dist/tools/token-audit.js.map +1 -0
- package/dist/tools/verify-completion.d.ts +2 -0
- package/dist/tools/verify-completion.js +154 -0
- package/dist/tools/verify-completion.js.map +1 -0
- package/dist/tools/what-changed.d.ts +2 -0
- package/dist/tools/what-changed.js +40 -0
- package/dist/tools/what-changed.js.map +1 -0
- package/dist/types.d.ts +78 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +52 -0
- package/src/cli/init.ts +133 -0
- package/src/index.ts +135 -0
- package/src/lib/config.ts +157 -0
- package/src/lib/embeddings.ts +118 -0
- package/src/lib/files.ts +59 -0
- package/src/lib/git-extractor.ts +137 -0
- package/src/lib/git.ts +89 -0
- package/src/lib/session-parser.ts +325 -0
- package/src/lib/state.ts +86 -0
- package/src/lib/timeline-db.ts +490 -0
- package/src/lib/triage.ts +255 -0
- package/src/profiles.ts +70 -0
- package/src/templates/config.yml +23 -0
- package/src/templates/triage.yml +27 -0
- package/src/tools/audit-workspace.ts +97 -0
- package/src/tools/checkpoint.ts +119 -0
- package/src/tools/clarify-intent.ts +191 -0
- package/src/tools/enrich-agent-task.ts +108 -0
- package/src/tools/generate-scorecard.ts +673 -0
- package/src/tools/log-correction.ts +89 -0
- package/src/tools/onboard-project.ts +214 -0
- package/src/tools/preflight-check.ts +263 -0
- package/src/tools/prompt-score.ts +150 -0
- package/src/tools/scan-sessions.ts +209 -0
- package/src/tools/scope-work.ts +238 -0
- package/src/tools/search-history.ts +145 -0
- package/src/tools/sequence-tasks.ts +182 -0
- package/src/tools/session-handoff.ts +125 -0
- package/src/tools/session-health.ts +107 -0
- package/src/tools/session-stats.ts +134 -0
- package/src/tools/sharpen-followup.ts +200 -0
- package/src/tools/timeline-view.ts +181 -0
- package/src/tools/token-audit.ts +259 -0
- package/src/tools/verify-completion.ts +159 -0
- package/src/tools/what-changed.ts +48 -0
- package/src/types.ts +87 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { getBranch } from "../lib/git.js";
|
|
3
|
+
import { appendLog, readLog, now } from "../lib/state.js";
|
|
4
|
+
const CATEGORIES = [
|
|
5
|
+
"vague_prompt",
|
|
6
|
+
"stale_context",
|
|
7
|
+
"wrong_assumption",
|
|
8
|
+
"wrong_file",
|
|
9
|
+
"wrong_scope",
|
|
10
|
+
"misread_intent",
|
|
11
|
+
"incomplete_work",
|
|
12
|
+
"style_mismatch",
|
|
13
|
+
"other",
|
|
14
|
+
];
|
|
15
|
+
export function registerLogCorrection(server) {
|
|
16
|
+
server.tool("log_correction", `Log when the user corrected your action. Tracks error patterns over time to identify what kinds of prompts lead to wrong outputs. Call this whenever the user says "no", "wrong", "not that", "I meant", or otherwise corrects your work.`, {
|
|
17
|
+
what_user_said: z.string().describe("The user's correction message"),
|
|
18
|
+
what_you_did_wrong: z.string().describe("What you did that was incorrect"),
|
|
19
|
+
root_cause: z.string().describe("Why — was it a vague prompt, stale context, wrong assumption, or something else?"),
|
|
20
|
+
category: z.enum(CATEGORIES).describe("Error category"),
|
|
21
|
+
}, async ({ what_user_said, what_you_did_wrong, root_cause, category }) => {
|
|
22
|
+
const entry = {
|
|
23
|
+
timestamp: now(),
|
|
24
|
+
branch: getBranch(),
|
|
25
|
+
user_said: what_user_said,
|
|
26
|
+
wrong_action: what_you_did_wrong,
|
|
27
|
+
root_cause,
|
|
28
|
+
category,
|
|
29
|
+
};
|
|
30
|
+
appendLog("corrections.jsonl", entry);
|
|
31
|
+
const corrections = readLog("corrections.jsonl");
|
|
32
|
+
const total = corrections.length;
|
|
33
|
+
if (total === 0) {
|
|
34
|
+
return {
|
|
35
|
+
content: [{
|
|
36
|
+
type: "text",
|
|
37
|
+
text: `## Correction Logged ✅\n\n**Category**: ${category}\n**Root cause**: ${root_cause}\n\nFirst correction logged.`,
|
|
38
|
+
}],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const categoryCounts = {};
|
|
42
|
+
for (const c of corrections) {
|
|
43
|
+
const cat = c.category || "other";
|
|
44
|
+
categoryCounts[cat] = (categoryCounts[cat] || 0) + 1;
|
|
45
|
+
}
|
|
46
|
+
const sorted = Object.entries(categoryCounts).sort((a, b) => b[1] - a[1]);
|
|
47
|
+
const topCategory = sorted[0];
|
|
48
|
+
const hints = {
|
|
49
|
+
vague_prompt: "💡 Most errors come from vague prompts. Call `clarify_intent` more aggressively.",
|
|
50
|
+
stale_context: "💡 Most errors from stale context. Call `checkpoint` more often and read workspace docs at session start.",
|
|
51
|
+
wrong_file: "💡 Most errors from wrong files. Always verify file paths before editing.",
|
|
52
|
+
wrong_assumption: "💡 Most errors from wrong assumptions. Ask clarifying questions instead of guessing.",
|
|
53
|
+
wrong_scope: "💡 Most errors from wrong scope. Confirm boundaries before starting work.",
|
|
54
|
+
misread_intent: "💡 Most errors from misread intent. Re-read user messages carefully before acting.",
|
|
55
|
+
incomplete_work: "💡 Most errors from incomplete work. Use `verify_completion` before declaring done.",
|
|
56
|
+
style_mismatch: "💡 Most errors from style mismatches. Check existing patterns before writing new code.",
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
content: [{
|
|
60
|
+
type: "text",
|
|
61
|
+
text: `## Correction Logged ✅
|
|
62
|
+
|
|
63
|
+
**Category**: ${category}
|
|
64
|
+
**Root cause**: ${root_cause}
|
|
65
|
+
|
|
66
|
+
### Error Pattern Summary (${total} total corrections)
|
|
67
|
+
${sorted.map(([k, v]) => `- ${k}: ${v} (${Math.round(v / total * 100)}%)`).join("\n")}
|
|
68
|
+
|
|
69
|
+
### Most Common: ${topCategory[0]} (${topCategory[1]}x)
|
|
70
|
+
|
|
71
|
+
${hints[topCategory[0]] || ""}`,
|
|
72
|
+
}],
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=log-correction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-correction.js","sourceRoot":"","sources":["../../src/tools/log-correction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAE1D,MAAM,UAAU,GAAG;IACjB,cAAc;IACd,eAAe;IACf,kBAAkB;IAClB,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,iBAAiB;IACjB,gBAAgB;IAChB,OAAO;CACC,CAAC;AAEX,MAAM,UAAU,qBAAqB,CAAC,MAAiB;IACrD,MAAM,CAAC,IAAI,CACT,gBAAgB,EAChB,2OAA2O,EAC3O;QACE,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;QACpE,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;QAC1E,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kFAAkF,CAAC;QACnH,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC;KACxD,EACD,KAAK,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE;QACrE,MAAM,KAAK,GAAG;YACZ,SAAS,EAAE,GAAG,EAAE;YAChB,MAAM,EAAE,SAAS,EAAE;YACnB,SAAS,EAAE,cAAc;YACzB,YAAY,EAAE,kBAAkB;YAChC,UAAU;YACV,QAAQ;SACT,CAAC;QACF,SAAS,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;QAE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AC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;mBAElE,WAAW,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC;;EAElD,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE;iBACtB,CAAC;SACH,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import { insertEvents, getLastIndexedTimestamp, getEventsTable, loadProjectMeta, saveProjectMeta } from "../lib/timeline-db.js";
|
|
5
|
+
import { findSessionDirs, parseAllSessions } from "../lib/session-parser.js";
|
|
6
|
+
import { extractGitHistory } from "../lib/git-extractor.js";
|
|
7
|
+
import { createEmbeddingProvider } from "../lib/embeddings.js";
|
|
8
|
+
import { execSync } from "child_process";
|
|
9
|
+
const GIT_DEPTH_MAP = {
|
|
10
|
+
all: undefined,
|
|
11
|
+
"3months": 90,
|
|
12
|
+
"6months": 180,
|
|
13
|
+
"1year": 365,
|
|
14
|
+
};
|
|
15
|
+
export function registerOnboardProject(server) {
|
|
16
|
+
server.tool("onboard_project", "Index a project's Claude Code sessions and git history into the timeline database for semantic search and chronological viewing.", {
|
|
17
|
+
project_dir: z.string().describe("Absolute path to the project directory"),
|
|
18
|
+
embedding_provider: z.enum(["local", "openai"]).default("local"),
|
|
19
|
+
openai_api_key: z.string().optional(),
|
|
20
|
+
git_depth: z.enum(["all", "6months", "1year", "3months"]).default("all"),
|
|
21
|
+
git_since: z.string().optional().describe("Override git_depth with exact start date (ISO: '2025-08-01')"),
|
|
22
|
+
git_authors: z.array(z.string()).optional().describe("Filter git commits to these authors. If omitted, auto-detects the primary author (most commits)."),
|
|
23
|
+
reindex: z.boolean().default(false).describe("If true, drop existing data and rebuild from scratch"),
|
|
24
|
+
}, async (params) => {
|
|
25
|
+
const { project_dir, embedding_provider, openai_api_key, git_depth, git_since, git_authors, reindex } = params;
|
|
26
|
+
// 1. Validate project_dir
|
|
27
|
+
if (!fs.existsSync(project_dir)) {
|
|
28
|
+
return { content: [{ type: "text", text: `❌ Directory not found: ${project_dir}` }] };
|
|
29
|
+
}
|
|
30
|
+
if (!fs.existsSync(path.join(project_dir, ".git"))) {
|
|
31
|
+
return { content: [{ type: "text", text: `❌ Not a git repository: ${project_dir}` }] };
|
|
32
|
+
}
|
|
33
|
+
const projectName = path.basename(project_dir);
|
|
34
|
+
const progress = [];
|
|
35
|
+
progress.push(`🔍 Onboarding project: **${projectName}** (${project_dir})`);
|
|
36
|
+
// Auto-detect git authors if not provided
|
|
37
|
+
let effectiveAuthors = git_authors;
|
|
38
|
+
if (!effectiveAuthors || effectiveAuthors.length === 0) {
|
|
39
|
+
try {
|
|
40
|
+
// Get the configured git user for this repo
|
|
41
|
+
const gitUser = execSync("git config user.name", { cwd: project_dir, encoding: "utf-8" }).trim();
|
|
42
|
+
if (gitUser) {
|
|
43
|
+
// Also find authors with >5% of commits to include collaborators
|
|
44
|
+
const authorCounts = execSync('git log --all --format="%an" | sort | uniq -c | sort -rn | head -10', { cwd: project_dir, encoding: "utf-8", maxBuffer: 1024 * 1024 }).trim().split("\n").map(line => {
|
|
45
|
+
const match = line.trim().match(/^(\d+)\s+(.+)$/);
|
|
46
|
+
return match ? { count: parseInt(match[1]), name: match[2] } : null;
|
|
47
|
+
}).filter(Boolean);
|
|
48
|
+
const totalCommits = authorCounts.reduce((s, a) => s + a.count, 0);
|
|
49
|
+
// Include git user + any author with >5% of commits (skip bots)
|
|
50
|
+
const botPatterns = /\[bot\]|dependabot|renovate|github-actions/i;
|
|
51
|
+
effectiveAuthors = authorCounts
|
|
52
|
+
.filter(a => (a.name === gitUser || a.count / totalCommits > 0.05) && !botPatterns.test(a.name))
|
|
53
|
+
.map(a => a.name);
|
|
54
|
+
if (effectiveAuthors.length === 0)
|
|
55
|
+
effectiveAuthors = [gitUser];
|
|
56
|
+
progress.push(`👤 Auto-detected authors: ${effectiveAuthors.join(", ")} (from git config + commit history)`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// If auto-detect fails, include all authors
|
|
61
|
+
progress.push("👤 Could not auto-detect authors — including all commits");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// 2. Find Claude session dir
|
|
65
|
+
const sessionDirs = findSessionDirs();
|
|
66
|
+
const projectSession = sessionDirs.find((s) => s.project === project_dir || s.projectName === projectName);
|
|
67
|
+
// 3. Determine incremental timestamps
|
|
68
|
+
let sessionSince;
|
|
69
|
+
let gitSince;
|
|
70
|
+
if (reindex) {
|
|
71
|
+
progress.push("♻️ Reindex requested — rebuilding from scratch");
|
|
72
|
+
// Drop existing data for this project
|
|
73
|
+
try {
|
|
74
|
+
const table = await getEventsTable(project_dir);
|
|
75
|
+
await table.delete(`project = "${project_dir}"`);
|
|
76
|
+
// Reset project metadata
|
|
77
|
+
const meta = {
|
|
78
|
+
project_dir: project_dir,
|
|
79
|
+
onboarded_at: new Date().toISOString(),
|
|
80
|
+
event_count: 0,
|
|
81
|
+
};
|
|
82
|
+
await saveProjectMeta(project_dir, meta);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Table may not exist yet
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const lastSession = await getLastIndexedTimestamp(projectName, "session");
|
|
90
|
+
const lastGit = await getLastIndexedTimestamp(projectName, "git");
|
|
91
|
+
if (lastSession) {
|
|
92
|
+
sessionSince = new Date(lastSession);
|
|
93
|
+
progress.push(`📋 Incremental session scan since ${lastSession}`);
|
|
94
|
+
}
|
|
95
|
+
if (lastGit) {
|
|
96
|
+
gitSince = new Date(lastGit);
|
|
97
|
+
progress.push(`📋 Incremental git scan since ${lastGit}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// 4. Parse sessions
|
|
101
|
+
let sessionEvents = [];
|
|
102
|
+
if (projectSession) {
|
|
103
|
+
progress.push(`📂 Scanning sessions in ${projectSession.sessionDir}`);
|
|
104
|
+
sessionEvents = parseAllSessions(projectSession.sessionDir, sessionSince ? { since: sessionSince } : undefined);
|
|
105
|
+
progress.push(` Found ${sessionEvents.length} new session events`);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
progress.push("⚠️ No Claude Code session directory found for this project");
|
|
109
|
+
}
|
|
110
|
+
// 5. Extract git history
|
|
111
|
+
let gitSinceDate;
|
|
112
|
+
if (git_since) {
|
|
113
|
+
gitSinceDate = new Date(git_since);
|
|
114
|
+
progress.push(`📅 Git history since ${git_since}`);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const depthDays = GIT_DEPTH_MAP[git_depth];
|
|
118
|
+
gitSinceDate = gitSince ?? (depthDays ? new Date(Date.now() - depthDays * 86400000) : undefined);
|
|
119
|
+
}
|
|
120
|
+
let gitEvents = extractGitHistory(project_dir, {
|
|
121
|
+
since: gitSinceDate,
|
|
122
|
+
maxCount: 10000,
|
|
123
|
+
});
|
|
124
|
+
// Filter by authors
|
|
125
|
+
if (effectiveAuthors && effectiveAuthors.length > 0) {
|
|
126
|
+
const authorPatterns = effectiveAuthors.map(a => a.toLowerCase());
|
|
127
|
+
const beforeCount = gitEvents.length;
|
|
128
|
+
gitEvents = gitEvents.filter((e) => {
|
|
129
|
+
try {
|
|
130
|
+
const meta = JSON.parse(e.metadata || "{}");
|
|
131
|
+
const author = (meta.author || "").toLowerCase();
|
|
132
|
+
return authorPatterns.some(p => author.includes(p));
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
progress.push(`👤 Filtered to authors [${effectiveAuthors.join(", ")}]: ${gitEvents.length}/${beforeCount} commits`);
|
|
139
|
+
}
|
|
140
|
+
progress.push(`📦 Found ${gitEvents.length} new git events`);
|
|
141
|
+
const allEvents = [...sessionEvents, ...gitEvents];
|
|
142
|
+
if (allEvents.length === 0) {
|
|
143
|
+
progress.push("\n✅ No new events to index. Database is up to date.");
|
|
144
|
+
return { content: [{ type: "text", text: progress.join("\n") }] };
|
|
145
|
+
}
|
|
146
|
+
// 6. Embed all events in batches
|
|
147
|
+
const embedder = createEmbeddingProvider({
|
|
148
|
+
provider: embedding_provider,
|
|
149
|
+
apiKey: openai_api_key,
|
|
150
|
+
});
|
|
151
|
+
const BATCH_SIZE = 50;
|
|
152
|
+
const totalBatches = Math.ceil(allEvents.length / BATCH_SIZE);
|
|
153
|
+
progress.push(`\n🧠 Embedding ${allEvents.length} events (${totalBatches} batches)...`);
|
|
154
|
+
for (let i = 0; i < allEvents.length; i += BATCH_SIZE) {
|
|
155
|
+
const batchNum = Math.floor(i / BATCH_SIZE) + 1;
|
|
156
|
+
const batch = allEvents.slice(i, i + BATCH_SIZE);
|
|
157
|
+
const texts = batch.map((e) => e.content || e.summary || "");
|
|
158
|
+
const vectors = await embedder.embedBatch(texts);
|
|
159
|
+
for (let j = 0; j < batch.length; j++) {
|
|
160
|
+
batch[j].vector = vectors[j];
|
|
161
|
+
}
|
|
162
|
+
progress.push(` Embedding batch ${batchNum}/${totalBatches}...`);
|
|
163
|
+
}
|
|
164
|
+
// 7. Insert into LanceDB (specify the project directory)
|
|
165
|
+
await insertEvents(allEvents, project_dir);
|
|
166
|
+
progress.push("💾 Inserted into database");
|
|
167
|
+
// 8. Summary
|
|
168
|
+
const prompts = allEvents.filter((e) => e.type === "prompt").length;
|
|
169
|
+
const commits = allEvents.filter((e) => e.type === "commit").length;
|
|
170
|
+
const corrections = allEvents.filter((e) => e.type === "correction").length;
|
|
171
|
+
const others = allEvents.length - prompts - commits - corrections;
|
|
172
|
+
// Get total count from project metadata
|
|
173
|
+
const meta = await loadProjectMeta(project_dir);
|
|
174
|
+
const totalEvents = meta?.event_count ?? allEvents.length;
|
|
175
|
+
progress.push(`\n✅ Indexed **${allEvents.length}** new events (${prompts} prompts, ${commits} commits, ${corrections} corrections${others > 0 ? `, ${others} other` : ""}). Total: **${totalEvents}** events.`);
|
|
176
|
+
return { content: [{ type: "text", text: progress.join("\n") }] };
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=onboard-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboard-project.js","sourceRoot":"","sources":["../../src/tools/onboard-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EACL,YAAY,EACZ,uBAAuB,EAEvB,cAAc,EAEd,eAAe,EACf,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,aAAa,GAAuC;IACxD,GAAG,EAAE,SAAS;IACd,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,GAAG;IACd,OAAO,EAAE,GAAG;CACb,CAAC;AAEF,MAAM,UAAU,sBAAsB,CAAC,MAAiB;IACtD,MAAM,CAAC,IAAI,CACT,iBAAiB,EACjB,kIAAkI,EAClI;QACE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;QAC1E,kBAAkB,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC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,iBAAiB,SAAS,CAAC,MAAM,kBAAkB,OAAO,aAAa,OAAO,aAAa,WAAW,eAAe,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,QAAQ,CAAC,CAAC,CAAC,EAAE,eAAe,WAAW,YAAY,CACjM,CAAC;QAEF,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;IACpE,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// Unified preflight_check — single entry point that triages and chains tools
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { triagePrompt } from "../lib/triage.js";
|
|
4
|
+
import { existsSync, statSync } from "fs";
|
|
5
|
+
import { resolve } from "path";
|
|
6
|
+
import { PROJECT_DIR } from "../lib/files.js";
|
|
7
|
+
import { getBranch, getStatus, getRecentCommits } from "../lib/git.js";
|
|
8
|
+
import { now } from "../lib/state.js";
|
|
9
|
+
import { findWorkspaceDocs } from "../lib/files.js";
|
|
10
|
+
import { getConfig } from "../lib/config.js";
|
|
11
|
+
import { searchSemantic } from "../lib/timeline-db.js";
|
|
12
|
+
import { basename } from "path";
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Helpers
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
/** Extract file paths from prompt text */
|
|
17
|
+
function extractFilePaths(prompt) {
|
|
18
|
+
const matches = prompt.match(/[\w\-./\\]+\.\w{1,6}/g) || [];
|
|
19
|
+
return [...new Set(matches)];
|
|
20
|
+
}
|
|
21
|
+
/** Verify files exist and return stats */
|
|
22
|
+
function verifyFiles(paths) {
|
|
23
|
+
const lines = [];
|
|
24
|
+
for (const p of paths) {
|
|
25
|
+
const abs = resolve(PROJECT_DIR, p);
|
|
26
|
+
if (!abs.startsWith(resolve(PROJECT_DIR)))
|
|
27
|
+
continue; // path traversal guard
|
|
28
|
+
if (existsSync(abs)) {
|
|
29
|
+
const s = statSync(abs);
|
|
30
|
+
lines.push(`✅ \`${p}\` — ${s.size} bytes, modified ${s.mtime.toISOString().slice(0, 16)}`);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
lines.push(`❌ \`${p}\` — not found`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return lines;
|
|
37
|
+
}
|
|
38
|
+
/** Get related project paths from config + env */
|
|
39
|
+
function getRelatedProjects() {
|
|
40
|
+
// From config
|
|
41
|
+
const config = getConfig();
|
|
42
|
+
const projects = [...config.related_projects];
|
|
43
|
+
// From env (legacy)
|
|
44
|
+
const envRelated = process.env.PREFLIGHT_RELATED;
|
|
45
|
+
if (envRelated) {
|
|
46
|
+
for (const p of envRelated.split(",").map(s => s.trim()).filter(Boolean)) {
|
|
47
|
+
if (!projects.some(pr => pr.path === p)) {
|
|
48
|
+
projects.push({ alias: basename(p), path: p });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return projects.filter(p => existsSync(p.path));
|
|
53
|
+
}
|
|
54
|
+
/** Search related projects for relevant context */
|
|
55
|
+
async function searchRelated(prompt, projects) {
|
|
56
|
+
if (projects.length === 0)
|
|
57
|
+
return [];
|
|
58
|
+
const results = [];
|
|
59
|
+
for (const query of [`${prompt} type interface schema`, `${prompt} API endpoint`]) {
|
|
60
|
+
try {
|
|
61
|
+
const hits = await searchSemantic(query, {
|
|
62
|
+
project_dirs: projects.map(p => p.path),
|
|
63
|
+
limit: 3,
|
|
64
|
+
});
|
|
65
|
+
for (const hit of hits) {
|
|
66
|
+
const name = basename(hit.project);
|
|
67
|
+
const content = hit.content.slice(0, 200);
|
|
68
|
+
const file = hit.source_file ? ` (${hit.source_file})` : "";
|
|
69
|
+
results.push(`- **${name}:** ${content}${file}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch { /* skip */ }
|
|
73
|
+
}
|
|
74
|
+
return results.slice(0, 6);
|
|
75
|
+
}
|
|
76
|
+
/** Inline clarify logic — extracts intent signals and git state */
|
|
77
|
+
function buildClarifySection(prompt) {
|
|
78
|
+
const sections = [];
|
|
79
|
+
const branch = getBranch();
|
|
80
|
+
const status = getStatus();
|
|
81
|
+
const recentCommits = getRecentCommits(5);
|
|
82
|
+
const dirtyCount = status ? status.split("\n").filter(Boolean).length : 0;
|
|
83
|
+
sections.push(`### Git State\nBranch: \`${branch}\` | Dirty files: ${dirtyCount}`);
|
|
84
|
+
if (status)
|
|
85
|
+
sections.push(`\`\`\`\n${status}\n\`\`\``);
|
|
86
|
+
sections.push(`Recent commits:\n\`\`\`\n${recentCommits || "(none)"}\n\`\`\``);
|
|
87
|
+
// Workspace priorities
|
|
88
|
+
const docs = findWorkspaceDocs();
|
|
89
|
+
const priorityDocs = Object.entries(docs)
|
|
90
|
+
.filter(([n]) => /gap|roadmap|current|todo|changelog/i.test(n))
|
|
91
|
+
.slice(0, 3);
|
|
92
|
+
if (priorityDocs.length > 0) {
|
|
93
|
+
sections.push(`### Workspace Priorities\n${priorityDocs.map(([n]) => `- \`${n}\``).join("\n")}`);
|
|
94
|
+
}
|
|
95
|
+
// Ambiguity signals
|
|
96
|
+
const issues = [];
|
|
97
|
+
if (/\b(it|them|the thing|that|those|this|these)\b/i.test(prompt))
|
|
98
|
+
issues.push("Contains vague pronouns — clarify what 'it'/'them' refers to");
|
|
99
|
+
if (/\b(fix|update|change|refactor|improve)\b/i.test(prompt) && !extractFilePaths(prompt).length)
|
|
100
|
+
issues.push("Vague verb without specific file targets");
|
|
101
|
+
if (prompt.trim().length < 40)
|
|
102
|
+
issues.push("Very short prompt — likely missing context");
|
|
103
|
+
if (issues.length > 0) {
|
|
104
|
+
sections.push(`### ⚠️ Clarification Needed\n${issues.map(i => `- ${i}`).join("\n")}`);
|
|
105
|
+
}
|
|
106
|
+
return sections;
|
|
107
|
+
}
|
|
108
|
+
/** Build scope section for multi-step */
|
|
109
|
+
function buildScopeSection(prompt) {
|
|
110
|
+
const sections = [];
|
|
111
|
+
const filePaths = extractFilePaths(prompt);
|
|
112
|
+
const fileVerification = verifyFiles(filePaths);
|
|
113
|
+
if (fileVerification.length > 0) {
|
|
114
|
+
sections.push(`### Referenced Files\n${fileVerification.join("\n")}`);
|
|
115
|
+
}
|
|
116
|
+
// Estimate complexity
|
|
117
|
+
const hasMultipleFiles = filePaths.length > 3;
|
|
118
|
+
const hasMultipleDirs = new Set(filePaths.map(f => f.split("/")[0])).size > 2;
|
|
119
|
+
const complexity = hasMultipleFiles && hasMultipleDirs ? "LARGE" : filePaths.length > 1 ? "MEDIUM" : "SMALL";
|
|
120
|
+
sections.push(`### Scope: ${complexity}`);
|
|
121
|
+
return sections;
|
|
122
|
+
}
|
|
123
|
+
/** Build sequence section for multi-step */
|
|
124
|
+
function buildSequenceSection(prompt) {
|
|
125
|
+
// Split prompt into sub-tasks
|
|
126
|
+
const subtasks = [];
|
|
127
|
+
// Split on "and", "then", numbered lists, bullet points
|
|
128
|
+
const parts = prompt
|
|
129
|
+
.split(/\b(?:then|after that|next|finally)\b|(?:,\s*and\s+)|(?:\band\b(?=\s+(?:update|add|remove|create|fix|change|refactor|implement|deploy)))/i)
|
|
130
|
+
.map(s => s.trim())
|
|
131
|
+
.filter(s => s.length > 5);
|
|
132
|
+
if (parts.length > 1) {
|
|
133
|
+
for (let i = 0; i < parts.length; i++) {
|
|
134
|
+
const risk = /schema|migrat|database|config|env|deploy/i.test(parts[i]) ? "🔴 HIGH" :
|
|
135
|
+
/api|route|endpoint/i.test(parts[i]) ? "🟡 MEDIUM" : "🟢 LOW";
|
|
136
|
+
subtasks.push(`${i + 1}. ${parts[i].charAt(0).toUpperCase() + parts[i].slice(1)} — Risk: ${risk}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
subtasks.push(`1. ${prompt.slice(0, 100)} — Risk: 🟡 MEDIUM`);
|
|
141
|
+
}
|
|
142
|
+
return [
|
|
143
|
+
`### Execution Plan`,
|
|
144
|
+
...subtasks,
|
|
145
|
+
"",
|
|
146
|
+
"### Checkpoints",
|
|
147
|
+
"- [ ] Verify after each step before proceeding",
|
|
148
|
+
"- [ ] Run tests between steps that touch different layers",
|
|
149
|
+
"- [ ] Commit after each successful step",
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
// ---------------------------------------------------------------------------
|
|
153
|
+
// Registration
|
|
154
|
+
// ---------------------------------------------------------------------------
|
|
155
|
+
export function registerPreflightCheck(server) {
|
|
156
|
+
server.tool("preflight_check", "Run a preflight check on your prompt before Claude starts working. Catches vague instructions, surfaces missing context from related services, and builds execution plans for complex tasks.", {
|
|
157
|
+
prompt: z.string().describe("The user's prompt to check"),
|
|
158
|
+
force_level: z.enum(["skip", "light", "full"]).optional().describe("Override triage — skip passes through, light does clarify only, full does everything"),
|
|
159
|
+
}, async ({ prompt, force_level }) => {
|
|
160
|
+
const ts = now();
|
|
161
|
+
// --- Force level overrides ---
|
|
162
|
+
if (force_level === "skip") {
|
|
163
|
+
return { content: [{ type: "text", text: "✅ Preflight: clear to proceed." }] };
|
|
164
|
+
}
|
|
165
|
+
// --- Triage ---
|
|
166
|
+
const preflightConfig = getConfig();
|
|
167
|
+
const triageConfig = {
|
|
168
|
+
alwaysCheck: preflightConfig.triage.rules.always_check,
|
|
169
|
+
skip: preflightConfig.triage.rules.skip,
|
|
170
|
+
crossServiceKeywords: preflightConfig.triage.rules.cross_service_keywords,
|
|
171
|
+
strictness: preflightConfig.triage.strictness,
|
|
172
|
+
relatedAliases: preflightConfig.related_projects.map(p => p.alias),
|
|
173
|
+
};
|
|
174
|
+
const triage = triagePrompt(prompt, triageConfig);
|
|
175
|
+
let effectiveLevel = triage.level;
|
|
176
|
+
if (force_level === "light")
|
|
177
|
+
effectiveLevel = "ambiguous";
|
|
178
|
+
if (force_level === "full")
|
|
179
|
+
effectiveLevel = "multi-step";
|
|
180
|
+
// --- Trivial ---
|
|
181
|
+
if (effectiveLevel === "trivial") {
|
|
182
|
+
return { content: [{ type: "text", text: "✅ Preflight: clear to proceed." }] };
|
|
183
|
+
}
|
|
184
|
+
const sections = [
|
|
185
|
+
`# 🛫 Preflight Check`,
|
|
186
|
+
`_${ts} | Triage: **${effectiveLevel}** (confidence: ${triage.confidence.toFixed(2)})_`,
|
|
187
|
+
`_Reasons: ${triage.reasons.join("; ")}_`,
|
|
188
|
+
];
|
|
189
|
+
// --- Clear: verify files ---
|
|
190
|
+
if (effectiveLevel === "clear") {
|
|
191
|
+
const filePaths = extractFilePaths(prompt);
|
|
192
|
+
const verification = verifyFiles(filePaths);
|
|
193
|
+
if (verification.length > 0) {
|
|
194
|
+
sections.push("", "## File Verification", ...verification);
|
|
195
|
+
}
|
|
196
|
+
sections.push("", "✅ Preflight: clear to proceed.");
|
|
197
|
+
return { content: [{ type: "text", text: sections.join("\n") }] };
|
|
198
|
+
}
|
|
199
|
+
// --- Ambiguous+: clarify ---
|
|
200
|
+
sections.push("", "## Clarification", ...buildClarifySection(prompt));
|
|
201
|
+
if (effectiveLevel === "ambiguous") {
|
|
202
|
+
return { content: [{ type: "text", text: sections.join("\n") }] };
|
|
203
|
+
}
|
|
204
|
+
// --- Cross-service: clarify + related projects ---
|
|
205
|
+
const relatedProjects = getRelatedProjects();
|
|
206
|
+
if (effectiveLevel === "cross-service" || effectiveLevel === "multi-step") {
|
|
207
|
+
if (relatedProjects.length > 0) {
|
|
208
|
+
sections.push("", `## Related Services (${relatedProjects.length} configured)`);
|
|
209
|
+
sections.push(relatedProjects.map(p => `- **${p.alias}:** \`${p.path}\``).join("\n"));
|
|
210
|
+
const relatedContext = await searchRelated(prompt, relatedProjects);
|
|
211
|
+
if (relatedContext.length > 0) {
|
|
212
|
+
sections.push("", "### Relevant Context from Related Projects", ...relatedContext);
|
|
213
|
+
}
|
|
214
|
+
if (triage.cross_service_hits && triage.cross_service_hits.length > 0) {
|
|
215
|
+
sections.push("", `### Cross-Service Matches: ${triage.cross_service_hits.join(", ")}`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (effectiveLevel === "cross-service") {
|
|
220
|
+
sections.push("", ...buildScopeSection(prompt));
|
|
221
|
+
return { content: [{ type: "text", text: sections.join("\n") }] };
|
|
222
|
+
}
|
|
223
|
+
// --- Multi-step: clarify + scope + sequence ---
|
|
224
|
+
sections.push("", "## Scope", ...buildScopeSection(prompt));
|
|
225
|
+
sections.push("", "## Sequence", ...buildSequenceSection(prompt));
|
|
226
|
+
return { content: [{ type: "text", text: sections.join("\n") }] };
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=preflight-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight-check.js","sourceRoot":"","sources":["../../src/tools/preflight-check.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAuC,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAO,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAgC,MAAM,eAAe,CAAC;AAC1G,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAQ,MAAM,MAAM,CAAC;AAEtC,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,0CAA0C;AAC1C,SAAS,gBAAg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