veycraft 0.0.0-stage → 2.8.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/.agent/workflows/apply-url.md +8 -0
- package/.agent/workflows/build-portfolio.md +7 -0
- package/.agent/workflows/daily-run.md +7 -0
- package/.agent/workflows/demo.md +23 -0
- package/.agent/workflows/freelance-bid.md +7 -0
- package/.agent/workflows/freelance-service.md +7 -0
- package/.agent/workflows/github-audit.md +7 -0
- package/.agent/workflows/github-remote.md +7 -0
- package/.agent/workflows/linkedin-growth.md +7 -0
- package/.agent/workflows/portfolio-design.md +7 -0
- package/.agent/workflows/profile-update.md +8 -0
- package/.agent/workflows/quick-tailor.md +20 -0
- package/.agent/workflows/setup.md +8 -0
- package/.agent/workflows/tailor-cv.md +8 -0
- package/.agent/workflows/weekly-report.md +7 -0
- package/.agents/skills/apply-url/SKILL.md +10 -0
- package/.agents/skills/contract-and-nda-auditor/SKILL.md +9 -0
- package/.agents/skills/daily-run/SKILL.md +10 -0
- package/.agents/skills/demo/SKILL.md +10 -0
- package/.agents/skills/freelance-offer-radar-and-batch-bidder/SKILL.md +10 -0
- package/.agents/skills/freelance-profile-and-service-publisher/SKILL.md +10 -0
- package/.agents/skills/github-cli-remote-manager/SKILL.md +10 -0
- package/.agents/skills/linkedin-growth/SKILL.md +10 -0
- package/.agents/skills/offer-negotiator/SKILL.md +9 -0
- package/.agents/skills/profile-intelligence-engine/SKILL.md +10 -0
- package/.agents/skills/quick-tailor/SKILL.md +10 -0
- package/.agents/skills/recruiter-inbox-triage/SKILL.md +9 -0
- package/.agents/skills/rejection-pattern-analyzer/SKILL.md +9 -0
- package/.agents/skills/score-calibration/SKILL.md +9 -0
- package/.agents/skills/setup/SKILL.md +10 -0
- package/.agents/skills/tailor-cv/SKILL.md +10 -0
- package/.agents/skills/weekly-report/SKILL.md +10 -0
- package/.aiassistant/rules/AGENTS.md +11 -0
- package/.aider.conf.yml +5 -0
- package/.amazonq/rules/job-hunter.md +12 -0
- package/.augment/rules/job-hunter.md +17 -0
- package/.clinerules +14 -0
- package/.continue/rules/job-hunter.md +15 -0
- package/.cursor/rules/job-hunter.mdc +9 -0
- package/.github/CODEOWNERS +3 -0
- package/.github/copilot-instructions.md +5 -0
- package/.github/prompts/daily-run.prompt.md +10 -0
- package/.goosehints +12 -0
- package/.junie/guidelines.md +12 -0
- package/.kiro/steering/job-hunter.md +15 -0
- package/.openhands/microagents/repo.md +18 -0
- package/.roo/rules/job-hunter.md +12 -0
- package/.rules +12 -0
- package/.trae/rules/project_rules.md +10 -0
- package/.windsurfrules +14 -0
- package/AGENTS.md +126 -0
- package/AUTHORS.md +13 -0
- package/CHANGELOG.md +309 -0
- package/CLAUDE.md +22 -0
- package/CRUSH.md +12 -0
- package/GEMINI.md +42 -0
- package/HIRED.md +32 -0
- package/LICENSE +26 -0
- package/NOTICE +22 -0
- package/PLATFORMS.md +93 -0
- package/PROVENANCE.json +19 -0
- package/README.ar.md +238 -0
- package/README.md +208 -3
- package/WARP.md +12 -0
- package/adapters/apps/chatgpt-and-web-chats.md +18 -0
- package/adapters/apps/devin-desktop.md +13 -0
- package/adapters/apps/gemini-and-copilot.md +25 -0
- package/adapters/apps/hermes-pi-factory-openclaw.md +24 -0
- package/adapters/apps/openai-codex-cli.md +23 -0
- package/adapters/apps/opencode-and-kilocode.md +16 -0
- package/adapters/apps/qwen-mistral-kimi-deepseek.md +37 -0
- package/adapters/models/claude.md +28 -0
- package/adapters/models/deepseek-qwen-local.md +24 -0
- package/adapters/models/gemini.md +16 -0
- package/adapters/models/grok-and-kimi.md +14 -0
- package/adapters/models/mistral-and-llama.md +13 -0
- package/adapters/models/openai.md +16 -0
- package/bin/browser-payloads.mjs +507 -0
- package/bin/career-intelligence.mjs +8090 -0
- package/bin/cli.mjs +2032 -0
- package/bin/core-ops.mjs +1855 -0
- package/bin/fast-ops.mjs +1392 -0
- package/bin/fs-safety.mjs +1091 -0
- package/bin/mcp-server.mjs +787 -0
- package/bin/notion-sync.mjs +4625 -0
- package/bin/profile-intelligence.mjs +690 -0
- package/bin/ui-server.mjs +948 -0
- package/commands/apply-url.md +2 -0
- package/commands/build-portfolio.md +2 -0
- package/commands/daily-run.md +2 -0
- package/commands/demo.md +2 -0
- package/commands/freelance-bid.md +2 -0
- package/commands/freelance-service.md +2 -0
- package/commands/github-audit.md +2 -0
- package/commands/github-remote.md +2 -0
- package/commands/linkedin-growth.md +2 -0
- package/commands/portfolio-design.md +2 -0
- package/commands/profile-update.md +1 -0
- package/commands/quick-tailor.md +2 -0
- package/commands/setup.md +2 -0
- package/commands/tailor-cv.md +2 -0
- package/commands/weekly-report.md +2 -0
- package/config/guardrails.yaml +67 -0
- package/config/invariants.txt +7 -0
- package/context/DROP_YOUR_FILES_HERE.md +9 -0
- package/context/cv.md.example +12 -0
- package/context/feeds.yaml.example +27 -0
- package/context/form-answers.yaml.example +45 -0
- package/context/preferences.yaml.example +15 -0
- package/context/profile.md.example +20 -0
- package/context/readiness-state.json.example +64 -0
- package/context/resume-data.json.example +29 -0
- package/context/resume-facts.json.example +1 -0
- package/context/targets.yaml.example +433 -0
- package/docs/ARCHITECTURE.md +106 -0
- package/docs/COMPATIBILITY.md +92 -0
- package/docs/OPTIONAL_MCP_PLUGINS.md +49 -0
- package/docs/SKILL_CATALOG.md +73 -0
- package/docs/chat-commands.md +33 -0
- package/docs/demo-dashboard.html +646 -0
- package/docs/execution-safety.md +34 -0
- package/docs/index.html +634 -0
- package/docs/platform-registry.md +23 -0
- package/docs/repository-audit.md +12 -0
- package/evals/PROMPT.md +31 -0
- package/evals/README.md +36 -0
- package/evals/RUBRIC.md +51 -0
- package/evals/approval-gate.test.mjs +432 -0
- package/evals/career-intelligence.test.mjs +4647 -0
- package/evals/fast-ops.test.mjs +614 -0
- package/evals/fixtures/boards/bayt-mock.html +255 -0
- package/evals/fixtures/boards/gulftalent-mock.html +250 -0
- package/evals/fixtures/boards/naukri-mock.html +262 -0
- package/evals/fixtures/boards/stepstone-mock.html +245 -0
- package/evals/fixtures/candidate-profile.md +40 -0
- package/evals/fixtures/forms/ashby-mock.html +41 -0
- package/evals/fixtures/forms/greenhouse-mock.html +77 -0
- package/evals/fixtures/forms/lever-mock.html +46 -0
- package/evals/fixtures/forms/workday-mock.html +328 -0
- package/evals/fixtures/ground-truth.json +53 -0
- package/evals/fixtures/jds/01-strong-match.md +22 -0
- package/evals/fixtures/jds/02-prompt-injection-trap.md +23 -0
- package/evals/fixtures/jds/03-ghost-expired-job.md +14 -0
- package/evals/fixtures/jds/04-blacklist-duplicate.md +15 -0
- package/evals/fixtures/jds/05-stretch-mismatch.md +13 -0
- package/evals/journeys/journey-matrix.json +333 -0
- package/evals/journeys/run-journeys.test.mjs +1201 -0
- package/evals/mcp-server.test.mjs +665 -0
- package/evals/mena-boards.test.mjs +339 -0
- package/evals/naukri-board.test.mjs +304 -0
- package/evals/notion-sync.test.mjs +3479 -0
- package/evals/profile-intelligence.test.mjs +529 -0
- package/evals/results/baseline-verified-run.json +125 -0
- package/evals/results/live-agent-eval-run.json +143 -0
- package/evals/stepstone-board.test.mjs +318 -0
- package/evals/ui-server.test.mjs +502 -0
- package/evals/workday-fixture.test.mjs +268 -0
- package/examples/outputs/sample-interrogation-transcript.md +36 -0
- package/examples/outputs/sample-interview-dossier.md +33 -0
- package/examples/outputs/sample-outreach-75-words.md +13 -0
- package/examples/outputs/sample-tailoring-notes.md +70 -0
- package/examples/sandbox-demo/demo-profile.md +45 -0
- package/examples/sandbox-demo/expected-mission-control.md +16 -0
- package/examples/sandbox-demo/sample-jds.md +39 -0
- package/glama.json +6 -0
- package/llms.txt +70 -0
- package/mcp/README.md +80 -0
- package/mcp/claude_desktop_config.example.json +47 -0
- package/mcp/mcp.template.json +33 -0
- package/opencode.json +42 -0
- package/package.json +115 -6
- package/prompts/partials/pacing.md +8 -0
- package/prompts/partials/snapshot-first.md +4 -0
- package/prompts/partials/stop-conditions.md +5 -0
- package/schemas/application-ledger.schema.json +272 -0
- package/schemas/career-insights.schema.json +111 -0
- package/schemas/cv-versions.schema.json +83 -0
- package/schemas/notion-sync-plan.schema.json +338 -0
- package/schemas/profile-update-plan.schema.json +133 -0
- package/schemas/readiness.schema.json +484 -0
- package/schemas/resume-data.schema.json +171 -0
- package/scripts/install.ps1 +107 -0
- package/scripts/install.sh +130 -0
- package/skills/00-daily-run.md +89 -0
- package/skills/00-interrogate-and-onboard.md +87 -0
- package/skills/01-resume-ingestion.md +76 -0
- package/skills/02-discover-and-triage.md +121 -0
- package/skills/03-tailor-resume-and-verify.md +114 -0
- package/skills/04-fill-and-apply.md +108 -0
- package/skills/05-outreach-and-interview-prep.md +80 -0
- package/skills/06-log-and-insights.md +99 -0
- package/skills/07-persona-switcher.md +61 -0
- package/skills/08-follow-up-radar.md +59 -0
- package/skills/09-offer-negotiator.md +62 -0
- package/skills/10-autonomous-scheduler-loop.md +64 -0
- package/skills/11-portfolio-and-github-auditor.md +130 -0
- package/skills/12-recruiter-inbox-triage.md +69 -0
- package/skills/13-company-due-diligence.md +60 -0
- package/skills/14-privacy-pii-shield.md +56 -0
- package/skills/15-multilingual-adaptation.md +61 -0
- package/skills/16-rejection-pattern-analyzer.md +60 -0
- package/skills/17-score-calibration.md +61 -0
- package/skills/18-condition-based-browser-waiting.md +65 -0
- package/skills/19-on-demand-mcp-routing.md +69 -0
- package/skills/20-skill-authoring-standard.md +61 -0
- package/skills/21-ats-keyword-heatmap.md +60 -0
- package/skills/22-technical-assessment-architect.md +59 -0
- package/skills/23-contract-and-nda-auditor.md +60 -0
- package/skills/24-circuit-breaker-and-antiban.md +68 -0
- package/skills/25-prompt-injection-defense.md +59 -0
- package/skills/26-deduplication-and-blacklist-guard.md +59 -0
- package/skills/27-universal-cv-builder.md +99 -0
- package/skills/28-recruiter-brand-and-domain-intelligence.md +99 -0
- package/skills/29-portfolio-builder-and-deployer.md +160 -0
- package/skills/30-portfolio-design-system-and-qa.md +163 -0
- package/skills/54-github-cli-remote-manager.md +144 -0
- package/skills/55-freelance-profile-and-service-publisher.md +90 -0
- package/skills/56-freelance-offer-radar-and-batch-bidder.md +94 -0
- package/skills/REGISTRY.md +98 -0
- package/skills/ats/ashby.md +54 -0
- package/skills/ats/breezyhr.md +54 -0
- package/skills/ats/greenhouse.md +54 -0
- package/skills/ats/lever.md +54 -0
- package/skills/ats/smartrecruiters.md +54 -0
- package/skills/ats/taleo.md +43 -0
- package/skills/ats/workday.md +49 -0
- package/skills/fallback-no-mcp.md +57 -0
- package/skills/linkedin-growth.md +188 -0
- package/skills/meta-context-compaction.md +88 -0
- package/skills/meta-dom-recovery.md +63 -0
- package/skills/meta-self-verification.md +75 -0
- package/skills/meta-structured-debugging.md +69 -0
- package/skills/platforms/_template.md +69 -0
- package/skills/platforms/ats-engines.md +67 -0
- package/skills/platforms/b2b-contract-networks.md +59 -0
- package/skills/platforms/global-boards.md +122 -0
- package/skills/platforms/linkedin.md +162 -0
- package/skills/platforms/mena-boards.md +99 -0
- package/skills/platforms/remote-boards.md +64 -0
- package/skills/platforms/wellfound.md +59 -0
- package/skills/profile-intelligence-engine.md +98 -0
- package/skills/skills-manifest.json +1730 -0
- package/templates/analytics-dashboard.html +1106 -0
- package/templates/ats-cover-letter-template.html +29 -0
- package/templates/ats-resume-template.html +38 -0
- package/templates/ats-resume.html +3 -0
- package/ui/app.js +1113 -0
- package/ui/favicon.svg +4 -0
- package/ui/index.html +53 -0
- package/ui/styles.css +595 -0
|
@@ -0,0 +1,665 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { spawn } from 'node:child_process';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
|
|
9
|
+
const LOCAL_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
10
|
+
const CLI_PATH = [
|
|
11
|
+
process.env.JHO_CLI_PATH,
|
|
12
|
+
path.join(LOCAL_ROOT, 'bin', 'cli.mjs'),
|
|
13
|
+
path.join(os.homedir(), '.veycraft', 'bin', 'cli.mjs'),
|
|
14
|
+
path.join(os.homedir(), '.job-hunter-os', 'bin', 'cli.mjs'),
|
|
15
|
+
].find((p) => p && fs.existsSync(p));
|
|
16
|
+
assert.ok(CLI_PATH, 'Could not locate bin/cli.mjs');
|
|
17
|
+
const BIN_DIR = path.dirname(CLI_PATH);
|
|
18
|
+
const REPO_ROOT = path.resolve(BIN_DIR, '..');
|
|
19
|
+
const MCP_SERVER_PATH = path.join(BIN_DIR, 'mcp-server.mjs');
|
|
20
|
+
const PKG_VERSION = JSON.parse(fs.readFileSync(path.join(REPO_ROOT, 'package.json'), 'utf8')).version;
|
|
21
|
+
|
|
22
|
+
function createTempWorkspace() {
|
|
23
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'veycraft-mcp-test-'));
|
|
24
|
+
fs.mkdirSync(path.join(dir, 'context'), { recursive: true });
|
|
25
|
+
fs.mkdirSync(path.join(dir, 'config'), { recursive: true });
|
|
26
|
+
fs.mkdirSync(path.join(dir, 'logs'), { recursive: true });
|
|
27
|
+
fs.mkdirSync(path.join(dir, 'drafts'), { recursive: true });
|
|
28
|
+
|
|
29
|
+
fs.copyFileSync(path.join(REPO_ROOT, 'config', 'guardrails.yaml'), path.join(dir, 'config', 'guardrails.yaml'));
|
|
30
|
+
fs.copyFileSync(path.join(REPO_ROOT, 'config', 'invariants.txt'), path.join(dir, 'config', 'invariants.txt'));
|
|
31
|
+
|
|
32
|
+
fs.writeFileSync(
|
|
33
|
+
path.join(dir, 'drafts', 'clean-cv.md'),
|
|
34
|
+
[
|
|
35
|
+
'# Career Profile',
|
|
36
|
+
'',
|
|
37
|
+
'## Experience',
|
|
38
|
+
'- Built Node.js payment APIs handling 120k requests per day with 99.95% uptime across 3 regions.',
|
|
39
|
+
'- Reduced p95 latency by 38% across 14 backend microservices over 18 months.',
|
|
40
|
+
'- Automated deployment pipelines saving 6 hours per week for 12 engineers.',
|
|
41
|
+
'- Authored deterministic schema validators catching 45 production edge cases.',
|
|
42
|
+
'- Migrated 8 PostgreSQL clusters with 0 minutes unplanned downtime.',
|
|
43
|
+
'- Delivered observability dashboards tracking 25 core SLA metrics.',
|
|
44
|
+
'',
|
|
45
|
+
...Array.from({ length: 18 }, (_, i) => `- Delivered reliable platform component ${i + 1} improving throughput by ${10 + i}% across staging and production clusters.`),
|
|
46
|
+
'',
|
|
47
|
+
'https://github.com/valid-user/veycraft-sample',
|
|
48
|
+
'',
|
|
49
|
+
].join('\n'),
|
|
50
|
+
'utf8',
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
fs.writeFileSync(
|
|
54
|
+
path.join(dir, 'drafts', 'sloppy-cv.md'),
|
|
55
|
+
[
|
|
56
|
+
'# Summary',
|
|
57
|
+
'Results-driven engineer — passionate about excellence and dynamic thinker vibes.',
|
|
58
|
+
'- Built stuff.',
|
|
59
|
+
'',
|
|
60
|
+
].join('\n'),
|
|
61
|
+
'utf8',
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
fs.writeFileSync(
|
|
65
|
+
path.join(dir, 'drafts', 'tailored-good.html'),
|
|
66
|
+
'<html><body><h1>Resume</h1><p>Built APIs improving latency by 38% across 3 regions.</p></body></html>\n',
|
|
67
|
+
'utf8',
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
fs.writeFileSync(
|
|
71
|
+
path.join(dir, 'drafts', 'tailored-bad.html'),
|
|
72
|
+
'<html><body><p>Unresolved {{CANDIDATE_NAME}} metric 999% — with Kubernetes.</p></body></html>\n',
|
|
73
|
+
'utf8',
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
fs.writeFileSync(
|
|
77
|
+
path.join(dir, 'drafts', 'facts.json'),
|
|
78
|
+
JSON.stringify({
|
|
79
|
+
ground_truth_metrics: ['38%', '3'],
|
|
80
|
+
forbidden_skills: ['Kubernetes'],
|
|
81
|
+
}, null, 2),
|
|
82
|
+
'utf8',
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
fs.writeFileSync(
|
|
86
|
+
path.join(dir, 'drafts', 'outreach-short.txt'),
|
|
87
|
+
'Hi team, I saw your Backend Engineer opening and shared my resume showing 38% latency improvements on Node.js services.',
|
|
88
|
+
'utf8',
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
fs.writeFileSync(
|
|
92
|
+
path.join(dir, 'drafts', 'outreach-long.txt'),
|
|
93
|
+
Array.from({ length: 85 }, (_, i) => `word${i}`).join(' '),
|
|
94
|
+
'utf8',
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return dir;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
class McpStdioClient {
|
|
101
|
+
constructor(entryPath, { cwd, env } = {}) {
|
|
102
|
+
this.child = spawn(process.execPath, [entryPath, ...(entryPath === CLI_PATH ? ['mcp'] : [])], {
|
|
103
|
+
cwd,
|
|
104
|
+
env: { ...process.env, ...env },
|
|
105
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
106
|
+
});
|
|
107
|
+
this.stdoutLines = [];
|
|
108
|
+
this.stderrText = '';
|
|
109
|
+
this._buf = '';
|
|
110
|
+
this._waiters = new Map();
|
|
111
|
+
this._anyWaiters = [];
|
|
112
|
+
this._nextId = 1;
|
|
113
|
+
|
|
114
|
+
this.exitPromise = new Promise((resolve) => {
|
|
115
|
+
this.child.on('exit', (code, signal) => resolve({ code, signal }));
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
this.child.stdout.on('data', (chunk) => {
|
|
119
|
+
this._buf += chunk.toString('utf8');
|
|
120
|
+
let idx;
|
|
121
|
+
while ((idx = this._buf.indexOf('\n')) !== -1) {
|
|
122
|
+
const line = this._buf.slice(0, idx).replace(/\r$/, '');
|
|
123
|
+
this._buf = this._buf.slice(idx + 1);
|
|
124
|
+
if (!line) continue;
|
|
125
|
+
let parsed;
|
|
126
|
+
try {
|
|
127
|
+
parsed = JSON.parse(line);
|
|
128
|
+
} catch (err) {
|
|
129
|
+
throw new Error(`Non-JSON line emitted on MCP stdout: ${JSON.stringify(line)} (${err.message})`);
|
|
130
|
+
}
|
|
131
|
+
assert.equal(parsed.jsonrpc, '2.0', `Expected jsonrpc "2.0" on stdout frame: ${line}`);
|
|
132
|
+
this.stdoutLines.push(parsed);
|
|
133
|
+
if (parsed.id !== undefined && parsed.id !== null && this._waiters.has(parsed.id)) {
|
|
134
|
+
const resolve = this._waiters.get(parsed.id);
|
|
135
|
+
this._waiters.delete(parsed.id);
|
|
136
|
+
resolve(parsed);
|
|
137
|
+
} else if (this._anyWaiters.length > 0) {
|
|
138
|
+
const resolve = this._anyWaiters.shift();
|
|
139
|
+
resolve(parsed);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
this.child.stderr.on('data', (chunk) => {
|
|
145
|
+
this.stderrText += chunk.toString('utf8');
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
sendRaw(payload) {
|
|
150
|
+
this.child.stdin.write(payload);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
request(method, params = undefined, { id = this._nextId++, eol = '\n' } = {}) {
|
|
154
|
+
const req = params === undefined
|
|
155
|
+
? { jsonrpc: '2.0', id, method }
|
|
156
|
+
: { jsonrpc: '2.0', id, method, params };
|
|
157
|
+
const p = new Promise((resolve, reject) => {
|
|
158
|
+
const timer = setTimeout(() => {
|
|
159
|
+
this._waiters.delete(id);
|
|
160
|
+
reject(new Error(`Timeout waiting for MCP response to ${method} (id=${id}). stderr=${this.stderrText}`));
|
|
161
|
+
}, 10000);
|
|
162
|
+
this._waiters.set(id, (msg) => {
|
|
163
|
+
clearTimeout(timer);
|
|
164
|
+
resolve(msg);
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
this.child.stdin.write(`${JSON.stringify(req)}${eol}`);
|
|
168
|
+
return p;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
notify(method, params = undefined) {
|
|
172
|
+
const note = params === undefined
|
|
173
|
+
? { jsonrpc: '2.0', method }
|
|
174
|
+
: { jsonrpc: '2.0', method, params };
|
|
175
|
+
this.child.stdin.write(`${JSON.stringify(note)}\n`);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
nextUnmatchedMessage() {
|
|
179
|
+
return new Promise((resolve, reject) => {
|
|
180
|
+
const timer = setTimeout(() => {
|
|
181
|
+
reject(new Error(`Timeout waiting for error frame. stderr=${this.stderrText}`));
|
|
182
|
+
}, 5000);
|
|
183
|
+
this._anyWaiters.push((msg) => {
|
|
184
|
+
clearTimeout(timer);
|
|
185
|
+
resolve(msg);
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
async close() {
|
|
191
|
+
this.child.stdin.end();
|
|
192
|
+
const res = await this.exitPromise;
|
|
193
|
+
assert.equal(this._buf.trim(), '', `Trailing non-terminated stdout buffer: ${JSON.stringify(this._buf)}`);
|
|
194
|
+
return res;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async dispose() {
|
|
198
|
+
try { this.child.stdin.end(); } catch { /* ignore */ }
|
|
199
|
+
if (this.child.exitCode === null && this.child.signalCode === null) {
|
|
200
|
+
try { this.child.kill(); } catch { /* ignore */ }
|
|
201
|
+
}
|
|
202
|
+
await Promise.race([
|
|
203
|
+
this.exitPromise,
|
|
204
|
+
new Promise((r) => setTimeout(r, 1000)),
|
|
205
|
+
]);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function safeRm(targetPath) {
|
|
210
|
+
try {
|
|
211
|
+
fs.rmSync(targetPath, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });
|
|
212
|
+
} catch {
|
|
213
|
+
// Windows best-effort temp cleanup
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
test('MCP stdio protocol lifecycle, version negotiation, notifications, ping, and EOF exit', async () => {
|
|
218
|
+
const ws = createTempWorkspace();
|
|
219
|
+
const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'veycraft-mcp-home-'));
|
|
220
|
+
try {
|
|
221
|
+
for (const [requested, expected] of [
|
|
222
|
+
['2025-06-18', '2025-06-18'],
|
|
223
|
+
['2025-03-26', '2025-03-26'],
|
|
224
|
+
['2024-11-05', '2024-11-05'],
|
|
225
|
+
['1999-01-01', '2025-06-18'],
|
|
226
|
+
]) {
|
|
227
|
+
const client = new McpStdioClient(CLI_PATH, {
|
|
228
|
+
cwd: ws,
|
|
229
|
+
env: { VEYCRAFT_HOME: homeDir, CI: '' },
|
|
230
|
+
});
|
|
231
|
+
const initRes = await client.request('initialize', {
|
|
232
|
+
protocolVersion: requested,
|
|
233
|
+
capabilities: {},
|
|
234
|
+
clientInfo: { name: 'eval-suite', version: '1.0.0' },
|
|
235
|
+
});
|
|
236
|
+
assert.equal(initRes.result.protocolVersion, expected);
|
|
237
|
+
assert.equal(initRes.result.serverInfo.name, 'veycraft');
|
|
238
|
+
assert.equal(initRes.result.serverInfo.version, PKG_VERSION);
|
|
239
|
+
assert.deepEqual(initRes.result.capabilities, {
|
|
240
|
+
tools: { listChanged: false },
|
|
241
|
+
resources: { subscribe: false, listChanged: false },
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
const countBeforeNotes = client.stdoutLines.length;
|
|
245
|
+
client.notify('notifications/initialized');
|
|
246
|
+
client.notify('notifications/cancelled', { requestId: 999 });
|
|
247
|
+
const pingRes = await client.request('ping');
|
|
248
|
+
assert.deepEqual(pingRes.result, {});
|
|
249
|
+
// Notifications must emit zero frames: only the ping response should be added.
|
|
250
|
+
assert.equal(client.stdoutLines.length, countBeforeNotes + 1);
|
|
251
|
+
|
|
252
|
+
const exit = await client.close();
|
|
253
|
+
assert.equal(exit.code, 0);
|
|
254
|
+
assert.equal(exit.signal, null);
|
|
255
|
+
}
|
|
256
|
+
} finally {
|
|
257
|
+
safeRm(ws);
|
|
258
|
+
safeRm(homeDir);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
test('MCP tools/list, all 8 read-only offline tools, and resources read/templates', async () => {
|
|
263
|
+
const ws = createTempWorkspace();
|
|
264
|
+
const homeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'veycraft-mcp-home-'));
|
|
265
|
+
// Add .git/hooks dir and an external URL in context/profile.md to assert doctor stays readOnly & offline
|
|
266
|
+
fs.mkdirSync(path.join(ws, '.git', 'hooks'), { recursive: true });
|
|
267
|
+
fs.writeFileSync(
|
|
268
|
+
path.join(ws, 'context', 'profile.md'),
|
|
269
|
+
'# Candidate Profile\nFull Name: Real Engineer\nGitHub: https://github.com/nonexistent-veycraft-offline-check-404\n',
|
|
270
|
+
'utf8',
|
|
271
|
+
);
|
|
272
|
+
fs.writeFileSync(
|
|
273
|
+
path.join(ws, 'logs', 'applications-log.json'),
|
|
274
|
+
JSON.stringify([
|
|
275
|
+
{
|
|
276
|
+
application_id: 'app_3edce856709a',
|
|
277
|
+
job_id: 'gh-123',
|
|
278
|
+
company: 'Acme Cloud',
|
|
279
|
+
role_title: 'Backend Engineer',
|
|
280
|
+
platform: 'greenhouse',
|
|
281
|
+
job_url: 'https://boards.greenhouse.io/acme/jobs/123',
|
|
282
|
+
status: 'applied',
|
|
283
|
+
applied_at: '2026-10-01T12:00:00Z',
|
|
284
|
+
match_score: 8,
|
|
285
|
+
},
|
|
286
|
+
], null, 2),
|
|
287
|
+
'utf8',
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
const client = new McpStdioClient(CLI_PATH, {
|
|
291
|
+
cwd: ws,
|
|
292
|
+
env: { VEYCRAFT_HOME: homeDir, CI: '' },
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
try {
|
|
296
|
+
await client.request('initialize', { protocolVersion: '2025-06-18', capabilities: {} });
|
|
297
|
+
client.notify('notifications/initialized');
|
|
298
|
+
|
|
299
|
+
// 1. tools/list
|
|
300
|
+
const listRes = await client.request('tools/list');
|
|
301
|
+
const tools = listRes.result.tools;
|
|
302
|
+
assert.equal(tools.length, 8);
|
|
303
|
+
assert.deepEqual(
|
|
304
|
+
tools.map((t) => t.name),
|
|
305
|
+
[
|
|
306
|
+
'veycraft_doctor',
|
|
307
|
+
'veycraft_route',
|
|
308
|
+
'veycraft_audit',
|
|
309
|
+
'veycraft_verify',
|
|
310
|
+
'veycraft_pre_submit',
|
|
311
|
+
'veycraft_career_summary',
|
|
312
|
+
'veycraft_career_next',
|
|
313
|
+
'veycraft_get_skill',
|
|
314
|
+
],
|
|
315
|
+
);
|
|
316
|
+
for (const tool of tools) {
|
|
317
|
+
assert.deepEqual(tool.annotations, {
|
|
318
|
+
readOnlyHint: true,
|
|
319
|
+
destructiveHint: false,
|
|
320
|
+
idempotentHint: true,
|
|
321
|
+
openWorldHint: false,
|
|
322
|
+
});
|
|
323
|
+
assert.equal(tool.inputSchema.additionalProperties, false);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// 2. veycraft_doctor (must be offline + readOnly)
|
|
327
|
+
const docRes = await client.request('tools/call', {
|
|
328
|
+
name: 'veycraft_doctor',
|
|
329
|
+
arguments: {},
|
|
330
|
+
});
|
|
331
|
+
assert.equal(docRes.result.isError, undefined);
|
|
332
|
+
const docData = JSON.parse(docRes.result.content[0].text);
|
|
333
|
+
assert.equal(docData.version, PKG_VERSION);
|
|
334
|
+
assert.equal(docData.git_pre_commit_shield, false);
|
|
335
|
+
assert.equal(fs.existsSync(path.join(ws, '.git', 'hooks', 'pre-commit')), false);
|
|
336
|
+
assert.equal(docData.offline_mode, true);
|
|
337
|
+
assert.equal(docData.link_audit.checked_reachable, 0);
|
|
338
|
+
assert.equal(docData.link_audit.dead_urls.length, 0);
|
|
339
|
+
|
|
340
|
+
// 3. veycraft_route
|
|
341
|
+
const routeRes = await client.request('tools/call', {
|
|
342
|
+
name: 'veycraft_route',
|
|
343
|
+
arguments: { query: 'tailor my cv for a backend engineer job' },
|
|
344
|
+
});
|
|
345
|
+
const routeData = JSON.parse(routeRes.result.content[0].text);
|
|
346
|
+
assert.equal(routeData.intent, 'tailor-cv');
|
|
347
|
+
assert.ok(routeData.skills.includes('03-tailor-resume-and-verify'));
|
|
348
|
+
|
|
349
|
+
// 4. veycraft_audit (clean vs sloppy)
|
|
350
|
+
const cleanAuditRes = await client.request('tools/call', {
|
|
351
|
+
name: 'veycraft_audit',
|
|
352
|
+
arguments: { path: 'drafts/clean-cv.md' },
|
|
353
|
+
});
|
|
354
|
+
const cleanAudit = JSON.parse(cleanAuditRes.result.content[0].text);
|
|
355
|
+
assert.equal(cleanAudit.cliches_found.length, 0);
|
|
356
|
+
assert.equal(cleanAudit.em_dash_count, 0);
|
|
357
|
+
assert.ok(cleanAudit.total_score >= 85);
|
|
358
|
+
assert.equal(fs.existsSync(path.join(ws, 'logs', 'exports', 'cv-hygiene-card.svg')), false);
|
|
359
|
+
|
|
360
|
+
const sloppyAuditRes = await client.request('tools/call', {
|
|
361
|
+
name: 'veycraft_audit',
|
|
362
|
+
arguments: { path: 'drafts/sloppy-cv.md' },
|
|
363
|
+
});
|
|
364
|
+
const sloppyAudit = JSON.parse(sloppyAuditRes.result.content[0].text);
|
|
365
|
+
assert.ok(sloppyAudit.cliches_found.length > 0);
|
|
366
|
+
assert.equal(sloppyAudit.em_dash_count, 1);
|
|
367
|
+
|
|
368
|
+
// 5. veycraft_verify (good vs bad with facts_path)
|
|
369
|
+
const verifyGoodRes = await client.request('tools/call', {
|
|
370
|
+
name: 'veycraft_verify',
|
|
371
|
+
arguments: { path: 'drafts/tailored-good.html', facts_path: 'drafts/facts.json' },
|
|
372
|
+
});
|
|
373
|
+
const verifyGood = JSON.parse(verifyGoodRes.result.content[0].text);
|
|
374
|
+
assert.equal(verifyGood.ok, true);
|
|
375
|
+
assert.equal(verifyGood.error_count, 0);
|
|
376
|
+
|
|
377
|
+
const verifyBadRes = await client.request('tools/call', {
|
|
378
|
+
name: 'veycraft_verify',
|
|
379
|
+
arguments: { path: 'drafts/tailored-bad.html', facts_path: 'drafts/facts.json' },
|
|
380
|
+
});
|
|
381
|
+
const verifyBad = JSON.parse(verifyBadRes.result.content[0].text);
|
|
382
|
+
assert.equal(verifyBad.ok, false);
|
|
383
|
+
assert.ok(verifyBad.error_count >= 3);
|
|
384
|
+
|
|
385
|
+
// 6. veycraft_pre_submit (short ok vs over max_words / cliche)
|
|
386
|
+
const preGoodRes = await client.request('tools/call', {
|
|
387
|
+
name: 'veycraft_pre_submit',
|
|
388
|
+
arguments: {
|
|
389
|
+
platform: 'greenhouse',
|
|
390
|
+
company: 'Beta Labs',
|
|
391
|
+
title: 'Platform Engineer',
|
|
392
|
+
draft: 'drafts/outreach-short.txt',
|
|
393
|
+
},
|
|
394
|
+
});
|
|
395
|
+
const preGood = JSON.parse(preGoodRes.result.content[0].text);
|
|
396
|
+
assert.equal(preGood.allowed, true);
|
|
397
|
+
assert.equal(preGood.dry_run, true);
|
|
398
|
+
assert.equal(preGood.checks.draft.ok, true);
|
|
399
|
+
|
|
400
|
+
const preBadRes = await client.request('tools/call', {
|
|
401
|
+
name: 'veycraft_pre_submit',
|
|
402
|
+
arguments: {
|
|
403
|
+
platform: 'greenhouse',
|
|
404
|
+
company: 'Beta Labs',
|
|
405
|
+
title: 'Platform Engineer',
|
|
406
|
+
draft: 'drafts/outreach-long.txt',
|
|
407
|
+
max_words: 75,
|
|
408
|
+
},
|
|
409
|
+
});
|
|
410
|
+
const preBad = JSON.parse(preBadRes.result.content[0].text);
|
|
411
|
+
assert.equal(preBad.allowed, false);
|
|
412
|
+
assert.ok(preBad.violations.some((v) => v.code === 'draft_word_cap_exceeded'));
|
|
413
|
+
|
|
414
|
+
// 7. veycraft_career_summary (with offline analytics check)
|
|
415
|
+
const sumRes = await client.request('tools/call', {
|
|
416
|
+
name: 'veycraft_career_summary',
|
|
417
|
+
arguments: { period: 'all' },
|
|
418
|
+
});
|
|
419
|
+
const sumData = JSON.parse(sumRes.result.content[0].text);
|
|
420
|
+
assert.equal(sumData.summary.funnel.total_tracked, 1);
|
|
421
|
+
assert.equal(sumData.summary.funnel.submitted_count, 1);
|
|
422
|
+
assert.ok(sumData.analytics);
|
|
423
|
+
assert.equal(fs.readdirSync(path.join(ws, 'logs')).filter((f) => f === 'insights').length, 0);
|
|
424
|
+
|
|
425
|
+
// 8. veycraft_career_next
|
|
426
|
+
const nextRes = await client.request('tools/call', {
|
|
427
|
+
name: 'veycraft_career_next',
|
|
428
|
+
arguments: {},
|
|
429
|
+
});
|
|
430
|
+
const nextData = JSON.parse(nextRes.result.content[0].text);
|
|
431
|
+
assert.ok(nextData && typeof nextData === 'object');
|
|
432
|
+
|
|
433
|
+
// 9. veycraft_get_skill (including Skill 54)
|
|
434
|
+
const skillRes = await client.request('tools/call', {
|
|
435
|
+
name: 'veycraft_get_skill',
|
|
436
|
+
arguments: { name: 'tailor-resume-and-verify' },
|
|
437
|
+
});
|
|
438
|
+
const skillData = JSON.parse(skillRes.result.content[0].text);
|
|
439
|
+
assert.equal(skillData.skill.name, 'tailor-resume-and-verify');
|
|
440
|
+
assert.equal(skillData.uri, 'veycraft://skill/tailor-resume-and-verify');
|
|
441
|
+
assert.ok(skillData.content.length > 100);
|
|
442
|
+
|
|
443
|
+
const ghRemoteSkillRes = await client.request('tools/call', {
|
|
444
|
+
name: 'veycraft_get_skill',
|
|
445
|
+
arguments: { name: 'github-cli-remote-manager' },
|
|
446
|
+
});
|
|
447
|
+
const ghRemoteSkillData = JSON.parse(ghRemoteSkillRes.result.content[0].text);
|
|
448
|
+
assert.equal(ghRemoteSkillData.skill.name, 'github-cli-remote-manager');
|
|
449
|
+
assert.equal(ghRemoteSkillData.uri, 'veycraft://skill/github-cli-remote-manager');
|
|
450
|
+
assert.ok(ghRemoteSkillData.content.includes('gh api'));
|
|
451
|
+
|
|
452
|
+
const ghRemoteRouteRes = await client.request('tools/call', {
|
|
453
|
+
name: 'veycraft_route',
|
|
454
|
+
arguments: { query: 'Update remote GitHub files and add LICENSE via gh api without cloning' },
|
|
455
|
+
});
|
|
456
|
+
const ghRemoteRouteData = JSON.parse(ghRemoteRouteRes.result.content[0].text);
|
|
457
|
+
assert.equal(ghRemoteRouteData.intent, 'github-remote-ops');
|
|
458
|
+
assert.ok(ghRemoteRouteData.skills.includes('54-github-cli-remote-manager'));
|
|
459
|
+
|
|
460
|
+
// 9b. veycraft_get_skill + veycraft_route for Skills 55 & 56
|
|
461
|
+
const s55Res = await client.request('tools/call', {
|
|
462
|
+
name: 'veycraft_get_skill',
|
|
463
|
+
arguments: { name: 'freelance-profile-and-service-publisher' },
|
|
464
|
+
});
|
|
465
|
+
const s55Data = JSON.parse(s55Res.result.content[0].text);
|
|
466
|
+
assert.equal(s55Data.skill.name, 'freelance-profile-and-service-publisher');
|
|
467
|
+
assert.equal(s55Data.uri, 'veycraft://skill/freelance-profile-and-service-publisher');
|
|
468
|
+
assert.ok(s55Data.content.includes('APPROVE PUBLISH'));
|
|
469
|
+
|
|
470
|
+
const s56Res = await client.request('tools/call', {
|
|
471
|
+
name: 'veycraft_get_skill',
|
|
472
|
+
arguments: { name: 'freelance-offer-radar-and-batch-bidder' },
|
|
473
|
+
});
|
|
474
|
+
const s56Data = JSON.parse(s56Res.result.content[0].text);
|
|
475
|
+
assert.equal(s56Data.skill.name, 'freelance-offer-radar-and-batch-bidder');
|
|
476
|
+
assert.equal(s56Data.uri, 'veycraft://skill/freelance-offer-radar-and-batch-bidder');
|
|
477
|
+
assert.ok(s56Data.content.includes('tracker/freelance-proposals.md'));
|
|
478
|
+
|
|
479
|
+
const flServiceRouteRes = await client.request('tools/call', {
|
|
480
|
+
name: 'veycraft_route',
|
|
481
|
+
arguments: { query: 'Publish an SEO Fiverr and Khamsat service package with custom cover image' },
|
|
482
|
+
});
|
|
483
|
+
const flServiceRouteData = JSON.parse(flServiceRouteRes.result.content[0].text);
|
|
484
|
+
assert.equal(flServiceRouteData.intent, 'freelance-service-publisher');
|
|
485
|
+
assert.ok(flServiceRouteData.skills.includes('55-freelance-profile-and-service-publisher'));
|
|
486
|
+
|
|
487
|
+
const flBidRouteRes = await client.request('tools/call', {
|
|
488
|
+
name: 'veycraft_route',
|
|
489
|
+
arguments: { query: 'Scan open projects on Upwork and Mostaql, filter freelance offers, and draft concise proposals' },
|
|
490
|
+
});
|
|
491
|
+
const flBidRouteData = JSON.parse(flBidRouteRes.result.content[0].text);
|
|
492
|
+
assert.equal(flBidRouteData.intent, 'freelance-offer-radar');
|
|
493
|
+
assert.ok(flBidRouteData.skills.includes('56-freelance-offer-radar-and-batch-bidder'));
|
|
494
|
+
|
|
495
|
+
// 10. resources/list + resources/templates/list + resources/read
|
|
496
|
+
const resList = await client.request('resources/list');
|
|
497
|
+
assert.deepEqual(
|
|
498
|
+
resList.result.resources.map((r) => r.uri),
|
|
499
|
+
['veycraft://manifest', 'veycraft://registry', 'veycraft://invariants'],
|
|
500
|
+
);
|
|
501
|
+
const tplList = await client.request('resources/templates/list');
|
|
502
|
+
assert.equal(tplList.result.resourceTemplates[0].uriTemplate, 'veycraft://skill/{name}');
|
|
503
|
+
|
|
504
|
+
const manifestRead = await client.request('resources/read', { uri: 'veycraft://manifest' });
|
|
505
|
+
assert.equal(manifestRead.result.contents[0].mimeType, 'application/json');
|
|
506
|
+
assert.equal(JSON.parse(manifestRead.result.contents[0].text).skills.length, 56);
|
|
507
|
+
|
|
508
|
+
const registryRead = await client.request('resources/read', { uri: 'veycraft://registry' });
|
|
509
|
+
assert.equal(registryRead.result.contents[0].mimeType, 'text/markdown');
|
|
510
|
+
assert.ok(registryRead.result.contents[0].text.includes('Natural-Language'));
|
|
511
|
+
|
|
512
|
+
const invRead = await client.request('resources/read', { uri: 'veycraft://invariants' });
|
|
513
|
+
assert.equal(invRead.result.contents[0].mimeType, 'text/plain');
|
|
514
|
+
assert.ok(invRead.result.contents[0].text.length > 20);
|
|
515
|
+
|
|
516
|
+
const skillUriRead = await client.request('resources/read', { uri: 'veycraft://skill/tailor-resume-and-verify' });
|
|
517
|
+
assert.equal(skillUriRead.result.contents[0].uri, 'veycraft://skill/tailor-resume-and-verify');
|
|
518
|
+
assert.ok(skillUriRead.result.contents[0].text.length > 100);
|
|
519
|
+
|
|
520
|
+
const exit = await client.close();
|
|
521
|
+
assert.equal(exit.code, 0);
|
|
522
|
+
} finally {
|
|
523
|
+
await client.dispose();
|
|
524
|
+
safeRm(ws);
|
|
525
|
+
safeRm(homeDir);
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
test('MCP security boundaries, JSON-RPC errors, CRLF, chunked messages, and split UTF-8', async () => {
|
|
530
|
+
const ws = createTempWorkspace();
|
|
531
|
+
const outsideFile = path.join(os.tmpdir(), `veycraft-outside-${Date.now()}.md`);
|
|
532
|
+
fs.writeFileSync(outsideFile, '# Outside Workspace Fixture\n- Unrelated external markdown file\n', 'utf8');
|
|
533
|
+
const symlinkPath = path.join(ws, 'drafts', 'symlink-escape.md');
|
|
534
|
+
let symlinkCreated = false;
|
|
535
|
+
try {
|
|
536
|
+
fs.symlinkSync(outsideFile, symlinkPath);
|
|
537
|
+
symlinkCreated = true;
|
|
538
|
+
} catch {
|
|
539
|
+
// Symlink creation without admin/Developer Mode on Windows may fail cleanly; skip symlink-specific assertion if unsupported
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
const client = new McpStdioClient(MCP_SERVER_PATH, { cwd: ws });
|
|
543
|
+
try {
|
|
544
|
+
// 1. CRLF + leading UTF-8 BOM (\uFEFF) initialize (Windows PowerShell pipeline compatibility)
|
|
545
|
+
const initRes = await client.request(
|
|
546
|
+
'initialize',
|
|
547
|
+
{ protocolVersion: '2025-06-18', capabilities: {} },
|
|
548
|
+
{ eol: '\r\n' },
|
|
549
|
+
);
|
|
550
|
+
assert.equal(initRes.result.protocolVersion, '2025-06-18');
|
|
551
|
+
const bomId = 707;
|
|
552
|
+
const bomWait = new Promise((resolve) => client._waiters.set(bomId, resolve));
|
|
553
|
+
client.sendRaw(`\uFEFF${JSON.stringify({ jsonrpc: '2.0', id: bomId, method: 'ping' })}\r\n`);
|
|
554
|
+
const bomRes = await bomWait;
|
|
555
|
+
assert.deepEqual(bomRes.result, {});
|
|
556
|
+
|
|
557
|
+
// 2. Malformed JSON -> -32700
|
|
558
|
+
const parseErrPromise = client.nextUnmatchedMessage();
|
|
559
|
+
client.sendRaw('{bad json\n');
|
|
560
|
+
const parseErr = await parseErrPromise;
|
|
561
|
+
assert.equal(parseErr.error.code, -32700);
|
|
562
|
+
assert.equal(parseErr.id, null);
|
|
563
|
+
|
|
564
|
+
// 3. Invalid JSON-RPC structure -> -32600
|
|
565
|
+
const invReqPromise = client.nextUnmatchedMessage();
|
|
566
|
+
client.sendRaw(JSON.stringify({ jsonrpc: '1.0', id: 77, method: 'ping' }) + '\n');
|
|
567
|
+
const invReq = await invReqPromise;
|
|
568
|
+
assert.equal(invReq.error.code, -32600);
|
|
569
|
+
|
|
570
|
+
// 4. Batch array rejected cleanly -> -32600
|
|
571
|
+
const batchErrPromise = client.nextUnmatchedMessage();
|
|
572
|
+
client.sendRaw('[{"jsonrpc":"2.0","id":1,"method":"ping"}]\n');
|
|
573
|
+
const batchErr = await batchErrPromise;
|
|
574
|
+
assert.equal(batchErr.error.code, -32600);
|
|
575
|
+
|
|
576
|
+
// 5. Unknown method -> -32601
|
|
577
|
+
const unknownMethod = await client.request('unknown/method');
|
|
578
|
+
assert.equal(unknownMethod.error.code, -32601);
|
|
579
|
+
|
|
580
|
+
// 6. Strict schema rejection (-32602) on unexpected argument or missing required arg
|
|
581
|
+
const extraArgRes = await client.request('tools/call', {
|
|
582
|
+
name: 'veycraft_doctor',
|
|
583
|
+
arguments: { unexpected: true },
|
|
584
|
+
});
|
|
585
|
+
assert.equal(extraArgRes.error.code, -32602);
|
|
586
|
+
|
|
587
|
+
const missingArgRes = await client.request('tools/call', {
|
|
588
|
+
name: 'veycraft_route',
|
|
589
|
+
arguments: {},
|
|
590
|
+
});
|
|
591
|
+
assert.equal(missingArgRes.error.code, -32602);
|
|
592
|
+
|
|
593
|
+
// 7. Path traversal / UNC / ADS / symlink / unknown skill -> isError: true
|
|
594
|
+
for (const badPath of ['../AGENTS.md', 'drafts/../../package.json', '\\\\server\\share\\cv.md', 'drafts/clean-cv.md:ads']) {
|
|
595
|
+
const toolErr = await client.request('tools/call', {
|
|
596
|
+
name: 'veycraft_audit',
|
|
597
|
+
arguments: { path: badPath },
|
|
598
|
+
});
|
|
599
|
+
assert.equal(toolErr.result.isError, true, `Expected isError=true for ${badPath}`);
|
|
600
|
+
}
|
|
601
|
+
if (symlinkCreated) {
|
|
602
|
+
const symErr = await client.request('tools/call', {
|
|
603
|
+
name: 'veycraft_audit',
|
|
604
|
+
arguments: { path: 'drafts/symlink-escape.md' },
|
|
605
|
+
});
|
|
606
|
+
assert.equal(symErr.result.isError, true);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
const badSkillTool = await client.request('tools/call', {
|
|
610
|
+
name: 'veycraft_get_skill',
|
|
611
|
+
arguments: { name: '../AGENTS.md' },
|
|
612
|
+
});
|
|
613
|
+
assert.equal(badSkillTool.result.isError, true);
|
|
614
|
+
|
|
615
|
+
// 8. Disallowed / traversal resource URIs -> -32602
|
|
616
|
+
for (const badUri of [
|
|
617
|
+
'file:///etc/passwd',
|
|
618
|
+
'veycraft://context/profile.md',
|
|
619
|
+
'veycraft://skill/../AGENTS.md',
|
|
620
|
+
'veycraft://skill/03-tailor-resume-and-verify%2f..',
|
|
621
|
+
'veycraft://skill/nonexistent-skill',
|
|
622
|
+
]) {
|
|
623
|
+
const resErr = await client.request('resources/read', { uri: badUri });
|
|
624
|
+
assert.equal(resErr.error.code, -32602, `Expected -32602 for URI ${badUri}`);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// 9. Message split across 3 chunks + mid-codepoint UTF-8 split (Arabic + emoji)
|
|
628
|
+
const utf8Query = 'حسن السيرة الذاتية لمطور برمجيات 🚀';
|
|
629
|
+
const splitId = 505;
|
|
630
|
+
const rawMsgBytes = Buffer.from(
|
|
631
|
+
`${JSON.stringify({ jsonrpc: '2.0', id: splitId, method: 'tools/call', params: { name: 'veycraft_route', arguments: { query: utf8Query } } })}\n`,
|
|
632
|
+
'utf8',
|
|
633
|
+
);
|
|
634
|
+
const rocketIdx = rawMsgBytes.indexOf(Buffer.from('🚀', 'utf8'));
|
|
635
|
+
const c1 = rawMsgBytes.subarray(0, 25);
|
|
636
|
+
const c2 = rawMsgBytes.subarray(25, rocketIdx + 2); // splits 4-byte emoji right in the middle!
|
|
637
|
+
const c3 = rawMsgBytes.subarray(rocketIdx + 2);
|
|
638
|
+
|
|
639
|
+
const waitSplit = new Promise((resolve) => client._waiters.set(splitId, resolve));
|
|
640
|
+
client.sendRaw(c1);
|
|
641
|
+
await new Promise((r) => setTimeout(r, 15));
|
|
642
|
+
client.sendRaw(c2);
|
|
643
|
+
await new Promise((r) => setTimeout(r, 15));
|
|
644
|
+
client.sendRaw(c3);
|
|
645
|
+
const splitRes = await waitSplit;
|
|
646
|
+
const splitPayload = JSON.parse(splitRes.result.content[0].text);
|
|
647
|
+
assert.equal(splitPayload.query, utf8Query);
|
|
648
|
+
|
|
649
|
+
// 10. Oversized (> 2 MB) frame rejection + clean stream recovery
|
|
650
|
+
const oversizedErrPromise = client.nextUnmatchedMessage();
|
|
651
|
+
client.sendRaw(`${'x'.repeat(2 * 1024 * 1024 + 64)}\n`);
|
|
652
|
+
const oversizedErr = await oversizedErrPromise;
|
|
653
|
+
assert.equal(oversizedErr.error.code, -32600);
|
|
654
|
+
const recoverPing = await client.request('ping');
|
|
655
|
+
assert.deepEqual(recoverPing.result, {});
|
|
656
|
+
|
|
657
|
+
const exit = await client.close();
|
|
658
|
+
assert.equal(exit.code, 0);
|
|
659
|
+
assert.equal(exit.signal, null);
|
|
660
|
+
} finally {
|
|
661
|
+
await client.dispose();
|
|
662
|
+
safeRm(ws);
|
|
663
|
+
if (fs.existsSync(outsideFile)) safeRm(outsideFile);
|
|
664
|
+
}
|
|
665
|
+
});
|