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,502 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import http from 'node:http';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
8
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
9
|
+
|
|
10
|
+
const LOCAL_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
11
|
+
const CLI_PATH = [
|
|
12
|
+
process.env.JHO_CLI_PATH,
|
|
13
|
+
path.join(LOCAL_ROOT, 'bin', 'cli.mjs'),
|
|
14
|
+
path.join(os.homedir(), '.veycraft', 'bin', 'cli.mjs'),
|
|
15
|
+
path.join(os.homedir(), '.job-hunter-os', 'bin', 'cli.mjs'),
|
|
16
|
+
].find((p) => p && fs.existsSync(p));
|
|
17
|
+
assert.ok(CLI_PATH, 'Could not locate bin/cli.mjs');
|
|
18
|
+
|
|
19
|
+
const BIN_DIR = path.dirname(CLI_PATH);
|
|
20
|
+
const REPO_ROOT = path.resolve(BIN_DIR, '..');
|
|
21
|
+
const UI_SERVER_PATH = path.join(BIN_DIR, 'ui-server.mjs');
|
|
22
|
+
const CORE_OPS_PATH = path.join(BIN_DIR, 'core-ops.mjs');
|
|
23
|
+
const CAREER_INTEL_PATH = path.join(BIN_DIR, 'career-intelligence.mjs');
|
|
24
|
+
const { startUiServer } = await import(pathToFileURL(UI_SERVER_PATH).href);
|
|
25
|
+
const { syncMcpConfigs } = await import(pathToFileURL(CORE_OPS_PATH).href);
|
|
26
|
+
const { computeApplicationId } = await import(pathToFileURL(CAREER_INTEL_PATH).href);
|
|
27
|
+
|
|
28
|
+
function rawHttpRequest(port, reqPath, { method = 'GET', headers = {}, body = null } = {}) {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
const req = http.request({
|
|
31
|
+
host: '127.0.0.1',
|
|
32
|
+
port,
|
|
33
|
+
path: reqPath,
|
|
34
|
+
method,
|
|
35
|
+
headers: {
|
|
36
|
+
Host: `127.0.0.1:${port}`,
|
|
37
|
+
...headers,
|
|
38
|
+
},
|
|
39
|
+
}, (res) => {
|
|
40
|
+
const chunks = [];
|
|
41
|
+
res.on('data', (c) => chunks.push(c));
|
|
42
|
+
res.on('end', () => {
|
|
43
|
+
resolve({
|
|
44
|
+
status: res.statusCode,
|
|
45
|
+
headers: res.headers,
|
|
46
|
+
body: Buffer.concat(chunks).toString('utf8'),
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
req.on('error', reject);
|
|
51
|
+
if (body !== null) req.write(body);
|
|
52
|
+
req.end();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
test('glama.json manifest and static ui/ zero-XSS invariants hold', () => {
|
|
57
|
+
const glamaPath = path.join(REPO_ROOT, 'glama.json');
|
|
58
|
+
assert.ok(fs.existsSync(glamaPath), 'glama.json must exist at repository root');
|
|
59
|
+
const glama = JSON.parse(fs.readFileSync(glamaPath, 'utf8'));
|
|
60
|
+
assert.equal(glama.$schema, 'https://glama.ai/mcp/schemas/server.json');
|
|
61
|
+
assert.deepEqual(glama.maintainers, ['redasalem']);
|
|
62
|
+
|
|
63
|
+
const uiDir = path.join(REPO_ROOT, 'ui');
|
|
64
|
+
for (const file of ['index.html', 'styles.css', 'app.js', 'favicon.svg']) {
|
|
65
|
+
const full = path.join(uiDir, file);
|
|
66
|
+
assert.ok(fs.existsSync(full), `Missing ui/${file}`);
|
|
67
|
+
const content = fs.readFileSync(full, 'utf8');
|
|
68
|
+
// Forbid dangerous DOM sinks & inline style/script attributes
|
|
69
|
+
const forbiddenTokens = ['inner' + 'HTML', 'outer' + 'HTML', 'insertAdjacent' + 'HTML', 'document.' + 'write'];
|
|
70
|
+
for (const tok of forbiddenTokens) {
|
|
71
|
+
assert.equal(content.includes(tok), false, `Forbidden DOM sink "${tok}" found in ui/${file}`);
|
|
72
|
+
}
|
|
73
|
+
if (file === 'index.html') {
|
|
74
|
+
assert.equal(/\sstyle\s*=/i.test(content), false, 'Inline style="" forbidden in ui/index.html');
|
|
75
|
+
assert.equal(/<script(?![^>]*\bsrc=)/i.test(content), false, 'Inline <script> forbidden in ui/index.html');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('UI server binds strictly to 127.0.0.1, serves static assets with CSP, and handles empty workspace gracefully', async (t) => {
|
|
81
|
+
const emptyDir = fs.mkdtempSync(path.join(os.tmpdir(), 'veycraft-ui-empty-'));
|
|
82
|
+
const handle = await startUiServer({
|
|
83
|
+
root: emptyDir,
|
|
84
|
+
source: REPO_ROOT,
|
|
85
|
+
port: 0,
|
|
86
|
+
openBrowser: false,
|
|
87
|
+
});
|
|
88
|
+
t.after(async () => {
|
|
89
|
+
await handle.close();
|
|
90
|
+
fs.rmSync(emptyDir, { recursive: true, force: true });
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
assert.equal(handle.host, '127.0.0.1');
|
|
94
|
+
assert.equal(handle.server.address().address, '127.0.0.1');
|
|
95
|
+
assert.ok(handle.port > 0);
|
|
96
|
+
|
|
97
|
+
for (const [route, expectedType] of [
|
|
98
|
+
['/', 'text/html; charset=utf-8'],
|
|
99
|
+
['/index.html', 'text/html; charset=utf-8'],
|
|
100
|
+
['/styles.css', 'text/css; charset=utf-8'],
|
|
101
|
+
['/app.js', 'text/javascript; charset=utf-8'],
|
|
102
|
+
['/favicon.svg', 'image/svg+xml'],
|
|
103
|
+
]) {
|
|
104
|
+
const res = await rawHttpRequest(handle.port, route);
|
|
105
|
+
assert.equal(res.status, 200, `Expected 200 on ${route}`);
|
|
106
|
+
assert.equal(res.headers['content-type'], expectedType);
|
|
107
|
+
assert.equal(res.headers['cache-control'], 'no-store');
|
|
108
|
+
assert.equal(res.headers['x-content-type-options'], 'nosniff');
|
|
109
|
+
assert.equal(res.headers['x-frame-options'], 'DENY');
|
|
110
|
+
assert.ok(String(res.headers['content-security-policy']).includes("default-src 'none'"));
|
|
111
|
+
assert.ok(String(res.headers['content-security-policy']).includes("script-src 'self'"));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
for (const apiRoute of ['/api/overview', '/api/doctor', '/api/applications', '/api/analytics', '/api/next', '/api/skills']) {
|
|
115
|
+
const res = await rawHttpRequest(handle.port, apiRoute);
|
|
116
|
+
assert.equal(res.status, 200, `Expected 200 on ${apiRoute} for empty workspace`);
|
|
117
|
+
const parsed = JSON.parse(res.body);
|
|
118
|
+
assert.equal(parsed.ok, true);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const overview = JSON.parse((await rawHttpRequest(handle.port, '/api/overview')).body);
|
|
122
|
+
assert.equal(overview.doctor.payload.initialized, false);
|
|
123
|
+
assert.equal(overview.doctor.payload.offline_mode, true);
|
|
124
|
+
assert.equal(overview.summary.funnel.total_tracked, 0);
|
|
125
|
+
|
|
126
|
+
const skills = JSON.parse((await rawHttpRequest(handle.port, '/api/skills')).body);
|
|
127
|
+
assert.equal(skills.skills_count, 56);
|
|
128
|
+
|
|
129
|
+
const skillDetail = JSON.parse((await rawHttpRequest(handle.port, '/api/skills/daily-run')).body);
|
|
130
|
+
assert.equal(skillDetail.uri, 'veycraft://skill/daily-run');
|
|
131
|
+
assert.ok(skillDetail.content.includes('## When to Use & Preconditions'));
|
|
132
|
+
|
|
133
|
+
const remoteSkillDetail = JSON.parse((await rawHttpRequest(handle.port, '/api/skills/github-cli-remote-manager')).body);
|
|
134
|
+
assert.equal(remoteSkillDetail.uri, 'veycraft://skill/github-cli-remote-manager');
|
|
135
|
+
assert.ok(remoteSkillDetail.content.includes('## Deterministic Step-by-Step Execution'));
|
|
136
|
+
|
|
137
|
+
const s55Detail = JSON.parse((await rawHttpRequest(handle.port, '/api/skills/freelance-profile-and-service-publisher')).body);
|
|
138
|
+
assert.equal(s55Detail.uri, 'veycraft://skill/freelance-profile-and-service-publisher');
|
|
139
|
+
assert.ok(s55Detail.content.includes('APPROVE PUBLISH'));
|
|
140
|
+
|
|
141
|
+
const s56Detail = JSON.parse((await rawHttpRequest(handle.port, '/api/skills/freelance-offer-radar-and-batch-bidder')).body);
|
|
142
|
+
assert.equal(s56Detail.uri, 'veycraft://skill/freelance-offer-radar-and-batch-bidder');
|
|
143
|
+
assert.ok(s56Detail.content.includes('Fit Score'));
|
|
144
|
+
|
|
145
|
+
// Empty workspace remains 100% empty on disk (read-only guarantee)
|
|
146
|
+
assert.deepEqual(fs.readdirSync(emptyDir), []);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('UI server enforces Host/Origin/Content-Type/size/method/path-traversal guards and auto-falls back on EADDRINUSE', async (t) => {
|
|
150
|
+
const wsDir = fs.mkdtempSync(path.join(os.tmpdir(), 'veycraft-ui-sec-'));
|
|
151
|
+
fs.writeFileSync(path.join(wsDir, '.env'), 'SECRET_KEY=top_secret_do_not_expose\n', 'utf8');
|
|
152
|
+
|
|
153
|
+
const handle1 = await startUiServer({
|
|
154
|
+
root: wsDir,
|
|
155
|
+
source: REPO_ROOT,
|
|
156
|
+
port: 0,
|
|
157
|
+
openBrowser: false,
|
|
158
|
+
});
|
|
159
|
+
// Occupy handle1.port and verify non-explicit port auto-falls back cleanly while explicit port rejects
|
|
160
|
+
const handleFallback = await startUiServer({
|
|
161
|
+
root: wsDir,
|
|
162
|
+
source: REPO_ROOT,
|
|
163
|
+
port: handle1.port,
|
|
164
|
+
portExplicit: false,
|
|
165
|
+
openBrowser: false,
|
|
166
|
+
stderr: { write: () => {} },
|
|
167
|
+
});
|
|
168
|
+
assert.notEqual(handleFallback.port, handle1.port);
|
|
169
|
+
|
|
170
|
+
await assert.rejects(
|
|
171
|
+
() => startUiServer({ root: wsDir, source: REPO_ROOT, port: handle1.port, portExplicit: true, openBrowser: false }),
|
|
172
|
+
/already in use/,
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
t.after(async () => {
|
|
176
|
+
await handleFallback.close();
|
|
177
|
+
await handle1.close();
|
|
178
|
+
fs.rmSync(wsDir, { recursive: true, force: true });
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// 1. DNS-rebinding Host spoof -> 403
|
|
182
|
+
const badHost = await rawHttpRequest(handle1.port, '/api/overview', {
|
|
183
|
+
headers: { Host: 'evil.attacker.example:4310' },
|
|
184
|
+
});
|
|
185
|
+
assert.equal(badHost.status, 403);
|
|
186
|
+
assert.equal(JSON.parse(badHost.body).error.code, 'invalid_host');
|
|
187
|
+
|
|
188
|
+
// 2. Cross-origin Origin header -> 403
|
|
189
|
+
const badOrigin = await rawHttpRequest(handle1.port, '/api/route', {
|
|
190
|
+
method: 'POST',
|
|
191
|
+
headers: {
|
|
192
|
+
Origin: 'http://evil.attacker.example',
|
|
193
|
+
'Content-Type': 'application/json',
|
|
194
|
+
},
|
|
195
|
+
body: JSON.stringify({ query: '/demo' }),
|
|
196
|
+
});
|
|
197
|
+
assert.equal(badOrigin.status, 403);
|
|
198
|
+
assert.equal(JSON.parse(badOrigin.body).error.code, 'cross_origin_blocked');
|
|
199
|
+
|
|
200
|
+
// 3. Non-JSON Content-Type on POST -> 415
|
|
201
|
+
const badMedia = await rawHttpRequest(handle1.port, '/api/route', {
|
|
202
|
+
method: 'POST',
|
|
203
|
+
headers: { 'Content-Type': 'text/plain' },
|
|
204
|
+
body: '{"query":"/demo"}',
|
|
205
|
+
});
|
|
206
|
+
assert.equal(badMedia.status, 415);
|
|
207
|
+
|
|
208
|
+
// 4. Disallowed HTTP method -> 405
|
|
209
|
+
const badMethod = await rawHttpRequest(handle1.port, '/api/applications', { method: 'DELETE' });
|
|
210
|
+
assert.equal(badMethod.status, 405);
|
|
211
|
+
|
|
212
|
+
// 5. Static & API path-traversal attempts -> 404/400/403 (zero file disclosure)
|
|
213
|
+
for (const attempt of ['/../package.json', '/%2e%2e/package.json', '/api/skills/..%2Fpackage.json']) {
|
|
214
|
+
const res = await rawHttpRequest(handle1.port, attempt);
|
|
215
|
+
assert.equal(res.status, 404, `Expected 404 for ${attempt}`);
|
|
216
|
+
assert.equal(res.body.includes('dependencies'), false);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
for (const badPath of ['../package.json', '.env']) {
|
|
220
|
+
const res = await rawHttpRequest(handle1.port, '/api/audit', {
|
|
221
|
+
method: 'POST',
|
|
222
|
+
headers: { 'Content-Type': 'application/json' },
|
|
223
|
+
body: JSON.stringify({ path: badPath }),
|
|
224
|
+
});
|
|
225
|
+
assert.ok([400, 403, 404].includes(res.status));
|
|
226
|
+
assert.equal(res.body.includes('top_secret_do_not_expose'), false);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// 6. Oversized body (> 512 KB) -> 413
|
|
230
|
+
const hugeBody = JSON.stringify({ text: 'x'.repeat(540 * 1024) });
|
|
231
|
+
const oversized = await rawHttpRequest(handle1.port, '/api/audit', {
|
|
232
|
+
method: 'POST',
|
|
233
|
+
headers: { 'Content-Type': 'application/json' },
|
|
234
|
+
body: hugeBody,
|
|
235
|
+
});
|
|
236
|
+
assert.equal(oversized.status, 413);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
test('UI server isolates third-party ledger records, preserves disk immutability, and executes Studio APIs', async (t) => {
|
|
240
|
+
const wsDir = fs.mkdtempSync(path.join(os.tmpdir(), 'veycraft-ui-ledger-'));
|
|
241
|
+
fs.mkdirSync(path.join(wsDir, 'logs'), { recursive: true });
|
|
242
|
+
fs.mkdirSync(path.join(wsDir, 'config'), { recursive: true });
|
|
243
|
+
fs.mkdirSync(path.join(wsDir, 'drafts'), { recursive: true });
|
|
244
|
+
fs.copyFileSync(path.join(REPO_ROOT, 'config', 'guardrails.yaml'), path.join(wsDir, 'config', 'guardrails.yaml'));
|
|
245
|
+
fs.copyFileSync(path.join(REPO_ROOT, 'config', 'invariants.txt'), path.join(wsDir, 'config', 'invariants.txt'));
|
|
246
|
+
|
|
247
|
+
const ledgerFile = path.join(wsDir, 'logs', 'applications-log.json');
|
|
248
|
+
const ledgerContent = JSON.stringify([
|
|
249
|
+
{
|
|
250
|
+
schema_version: '2.0',
|
|
251
|
+
application_id: computeApplicationId('gh-owner-01'),
|
|
252
|
+
job_id: 'gh-owner-01',
|
|
253
|
+
company: 'Owner Fintech',
|
|
254
|
+
title: 'Senior Backend Engineer',
|
|
255
|
+
platform: 'greenhouse',
|
|
256
|
+
status: 'applied',
|
|
257
|
+
match_score: 8.7,
|
|
258
|
+
applied_at: '2026-11-20T10:00:00Z',
|
|
259
|
+
updated_at: '2026-11-20T10:00:00Z',
|
|
260
|
+
provenance: { created_by: 'test', third_party_subject: false, receipt_verified: true },
|
|
261
|
+
notes: 'receipt: "Thank you for applying to Owner Fintech"',
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
schema_version: '2.0',
|
|
265
|
+
application_id: computeApplicationId('gh-friend-02'),
|
|
266
|
+
job_id: 'gh-friend-02',
|
|
267
|
+
company: 'ThirdParty Corp',
|
|
268
|
+
title: 'Data Analyst',
|
|
269
|
+
platform: 'lever',
|
|
270
|
+
status: 'prepared',
|
|
271
|
+
provenance: { created_by: 'test', third_party_subject: true },
|
|
272
|
+
},
|
|
273
|
+
], null, 2);
|
|
274
|
+
fs.writeFileSync(ledgerFile, ledgerContent, 'utf8');
|
|
275
|
+
|
|
276
|
+
const sampleCv = path.join(wsDir, 'drafts', 'sample-cv.md');
|
|
277
|
+
fs.writeFileSync(
|
|
278
|
+
sampleCv,
|
|
279
|
+
[
|
|
280
|
+
'# Backend Profile',
|
|
281
|
+
...Array.from({ length: 16 }, (_, i) => `- Engineered payment service ${i + 1} reducing p95 latency by ${15 + i}% across 4 regions.`),
|
|
282
|
+
'',
|
|
283
|
+
].join('\n'),
|
|
284
|
+
'utf8',
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
const handle = await startUiServer({
|
|
288
|
+
root: wsDir,
|
|
289
|
+
source: REPO_ROOT,
|
|
290
|
+
port: 0,
|
|
291
|
+
openBrowser: false,
|
|
292
|
+
});
|
|
293
|
+
t.after(async () => {
|
|
294
|
+
await handle.close();
|
|
295
|
+
fs.rmSync(wsDir, { recursive: true, force: true });
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
const appsRes = JSON.parse((await rawHttpRequest(handle.port, '/api/applications')).body);
|
|
299
|
+
assert.equal(appsRes.kanban.total_owner_records, 1);
|
|
300
|
+
assert.equal(appsRes.kanban.third_party_excluded, 1);
|
|
301
|
+
assert.equal(appsRes.kanban.columns.applied.length, 1);
|
|
302
|
+
assert.equal(appsRes.kanban.columns.applied[0].company, 'Owner Fintech');
|
|
303
|
+
assert.equal(JSON.stringify(appsRes).includes('ThirdParty Corp'), false);
|
|
304
|
+
|
|
305
|
+
const routeRes = JSON.parse((await rawHttpRequest(handle.port, '/api/route', {
|
|
306
|
+
method: 'POST',
|
|
307
|
+
headers: { 'Content-Type': 'application/json' },
|
|
308
|
+
body: JSON.stringify({ query: '/quick-tailor' }),
|
|
309
|
+
})).body);
|
|
310
|
+
assert.equal(routeRes.route.intent, 'tailor-cv');
|
|
311
|
+
|
|
312
|
+
const inlineAudit = JSON.parse((await rawHttpRequest(handle.port, '/api/audit', {
|
|
313
|
+
method: 'POST',
|
|
314
|
+
headers: { 'Content-Type': 'application/json' },
|
|
315
|
+
body: JSON.stringify({ text: fs.readFileSync(sampleCv, 'utf8'), format: 'md' }),
|
|
316
|
+
})).body);
|
|
317
|
+
assert.ok(inlineAudit.audit.total_score >= 80);
|
|
318
|
+
|
|
319
|
+
const fileAudit = JSON.parse((await rawHttpRequest(handle.port, '/api/audit', {
|
|
320
|
+
method: 'POST',
|
|
321
|
+
headers: { 'Content-Type': 'application/json' },
|
|
322
|
+
body: JSON.stringify({ path: 'drafts/sample-cv.md' }),
|
|
323
|
+
})).body);
|
|
324
|
+
assert.equal(fileAudit.audit.total_score, inlineAudit.audit.total_score);
|
|
325
|
+
|
|
326
|
+
const verifyBad = JSON.parse((await rawHttpRequest(handle.port, '/api/verify', {
|
|
327
|
+
method: 'POST',
|
|
328
|
+
headers: { 'Content-Type': 'application/json' },
|
|
329
|
+
body: JSON.stringify({
|
|
330
|
+
text: '<p>Hello {{CANDIDATE_NAME}} with 999% and Kubernetes.</p>',
|
|
331
|
+
format: 'html',
|
|
332
|
+
facts_json: { ground_truth_metrics: ['38%'], forbidden_skills: ['Kubernetes'] },
|
|
333
|
+
}),
|
|
334
|
+
})).body);
|
|
335
|
+
assert.equal(verifyBad.verification.ok, false);
|
|
336
|
+
assert.ok(verifyBad.verification.error_count >= 2);
|
|
337
|
+
|
|
338
|
+
const preSubmitRes = JSON.parse((await rawHttpRequest(handle.port, '/api/pre-submit', {
|
|
339
|
+
method: 'POST',
|
|
340
|
+
headers: { 'Content-Type': 'application/json' },
|
|
341
|
+
body: JSON.stringify({
|
|
342
|
+
platform: 'greenhouse',
|
|
343
|
+
company: 'New Co',
|
|
344
|
+
title: 'Platform Engineer',
|
|
345
|
+
text: 'Concise hiring manager note highlighting verified Node.js reliability work.',
|
|
346
|
+
}),
|
|
347
|
+
})).body);
|
|
348
|
+
assert.equal(preSubmitRes.evaluation.allowed, true);
|
|
349
|
+
|
|
350
|
+
// Confirm ledger on disk is byte-for-byte unchanged
|
|
351
|
+
assert.equal(fs.readFileSync(ledgerFile, 'utf8'), ledgerContent);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
test('sync-mcp --with-veycraft supports --dry-run, atomic .veycraft.bak backups, and custom entry preservation', () => {
|
|
355
|
+
const wsDir = fs.mkdtempSync(path.join(os.tmpdir(), 'veycraft-sync-mcp-'));
|
|
356
|
+
const fakeHome = fs.mkdtempSync(path.join(os.tmpdir(), 'veycraft-sync-home-'));
|
|
357
|
+
try {
|
|
358
|
+
// 1. Default sync-mcp (without --with-veycraft) does NOT inject veycraft
|
|
359
|
+
syncMcpConfigs({
|
|
360
|
+
root: wsDir,
|
|
361
|
+
isGlobal: false,
|
|
362
|
+
source: REPO_ROOT,
|
|
363
|
+
home: fakeHome,
|
|
364
|
+
env: {},
|
|
365
|
+
platform: 'linux',
|
|
366
|
+
withVeycraft: false,
|
|
367
|
+
dryRun: false,
|
|
368
|
+
});
|
|
369
|
+
const initialMcp = JSON.parse(fs.readFileSync(path.join(wsDir, '.mcp.json'), 'utf8'));
|
|
370
|
+
assert.ok(initialMcp.mcpServers.playwright);
|
|
371
|
+
assert.equal(initialMcp.mcpServers.veycraft, undefined);
|
|
372
|
+
|
|
373
|
+
// 2. --with-veycraft --dry-run plans updates with ZERO disk writes
|
|
374
|
+
const dryRes = syncMcpConfigs({
|
|
375
|
+
root: wsDir,
|
|
376
|
+
isGlobal: false,
|
|
377
|
+
source: REPO_ROOT,
|
|
378
|
+
home: fakeHome,
|
|
379
|
+
env: {},
|
|
380
|
+
platform: 'linux',
|
|
381
|
+
withVeycraft: true,
|
|
382
|
+
dryRun: true,
|
|
383
|
+
});
|
|
384
|
+
assert.equal(dryRes.dry_run, true);
|
|
385
|
+
assert.ok(dryRes.updated > 0);
|
|
386
|
+
assert.equal(fs.existsSync(path.join(wsDir, '.mcp.json.veycraft.bak')), false);
|
|
387
|
+
assert.equal(JSON.parse(fs.readFileSync(path.join(wsDir, '.mcp.json'), 'utf8')).mcpServers.veycraft, undefined);
|
|
388
|
+
|
|
389
|
+
// 3. --with-veycraft writes veycraft across JSON, VS Code, and Codex TOML + creates .veycraft.bak backups
|
|
390
|
+
const applyRes = syncMcpConfigs({
|
|
391
|
+
root: wsDir,
|
|
392
|
+
isGlobal: false,
|
|
393
|
+
source: REPO_ROOT,
|
|
394
|
+
home: fakeHome,
|
|
395
|
+
env: {},
|
|
396
|
+
platform: 'win32',
|
|
397
|
+
withVeycraft: true,
|
|
398
|
+
dryRun: false,
|
|
399
|
+
});
|
|
400
|
+
assert.ok(applyRes.updated > 0);
|
|
401
|
+
assert.equal(fs.existsSync(path.join(wsDir, '.mcp.json.veycraft.bak')), true);
|
|
402
|
+
|
|
403
|
+
const updatedMcp = JSON.parse(fs.readFileSync(path.join(wsDir, '.mcp.json'), 'utf8'));
|
|
404
|
+
assert.equal(updatedMcp.mcpServers.veycraft.command, 'cmd');
|
|
405
|
+
assert.deepEqual(updatedMcp.mcpServers.veycraft.args, ['/c', 'npx', '-y', 'veycraft', 'mcp']);
|
|
406
|
+
|
|
407
|
+
const vsMcp = JSON.parse(fs.readFileSync(path.join(wsDir, '.vscode', 'mcp.json'), 'utf8'));
|
|
408
|
+
assert.equal(vsMcp.servers.veycraft.type, 'stdio');
|
|
409
|
+
|
|
410
|
+
const codexToml = fs.readFileSync(path.join(wsDir, '.codex', 'config.toml'), 'utf8');
|
|
411
|
+
assert.ok(codexToml.includes('[mcp_servers.veycraft]'));
|
|
412
|
+
|
|
413
|
+
// 4. Custom user veycraft entry is preserved and never clobbered
|
|
414
|
+
updatedMcp.mcpServers.veycraft = { command: 'node', args: ['/custom/veycraft-mcp.mjs'] };
|
|
415
|
+
fs.writeFileSync(path.join(wsDir, '.mcp.json'), JSON.stringify(updatedMcp, null, 2) + '\n', 'utf8');
|
|
416
|
+
|
|
417
|
+
const preserveRes = syncMcpConfigs({
|
|
418
|
+
root: wsDir,
|
|
419
|
+
isGlobal: false,
|
|
420
|
+
source: REPO_ROOT,
|
|
421
|
+
home: fakeHome,
|
|
422
|
+
env: {},
|
|
423
|
+
platform: 'win32',
|
|
424
|
+
withVeycraft: true,
|
|
425
|
+
dryRun: false,
|
|
426
|
+
});
|
|
427
|
+
assert.ok(preserveRes.warnings.some((w) => w.includes('Preserved existing custom veycraft MCP server')));
|
|
428
|
+
const afterPreserve = JSON.parse(fs.readFileSync(path.join(wsDir, '.mcp.json'), 'utf8'));
|
|
429
|
+
assert.equal(afterPreserve.mcpServers.veycraft.command, 'node');
|
|
430
|
+
|
|
431
|
+
// 5. CLI subprocess check for `veycraft sync-mcp --with-veycraft --dry-run --json`
|
|
432
|
+
const cliDry = spawnSync(process.execPath, [CLI_PATH, 'sync-mcp', '--with-veycraft', '--dry-run', '--json'], {
|
|
433
|
+
cwd: wsDir,
|
|
434
|
+
env: { ...process.env, HOME: fakeHome, USERPROFILE: fakeHome },
|
|
435
|
+
encoding: 'utf8',
|
|
436
|
+
});
|
|
437
|
+
assert.equal(cliDry.status, 0, cliDry.stderr);
|
|
438
|
+
assert.equal(JSON.parse(cliDry.stdout).with_veycraft, true);
|
|
439
|
+
} finally {
|
|
440
|
+
fs.rmSync(wsDir, { recursive: true, force: true });
|
|
441
|
+
fs.rmSync(fakeHome, { recursive: true, force: true });
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
test('CLI subprocess `veycraft ui --port 0 --no-open --workspace <dir>` boots cleanly and serves /api/overview', async (t) => {
|
|
446
|
+
const wsDir = fs.mkdtempSync(path.join(os.tmpdir(), 'veycraft-ui-cli-'));
|
|
447
|
+
const child = spawn(process.execPath, [CLI_PATH, 'ui', '--port', '0', '--no-open', '--workspace', wsDir], {
|
|
448
|
+
cwd: REPO_ROOT,
|
|
449
|
+
env: { ...process.env, CI: '1', NO_COLOR: '1' },
|
|
450
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
const exitPromise = new Promise((resolve) => {
|
|
454
|
+
child.on('exit', (code, signal) => resolve({ code, signal }));
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
t.after(async () => {
|
|
458
|
+
if (child.exitCode === null && child.signalCode === null) {
|
|
459
|
+
child.kill();
|
|
460
|
+
await exitPromise;
|
|
461
|
+
}
|
|
462
|
+
fs.rmSync(wsDir, { recursive: true, force: true });
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
const url = await new Promise((resolve, reject) => {
|
|
466
|
+
let out = '';
|
|
467
|
+
let errOut = '';
|
|
468
|
+
const timer = setTimeout(() => {
|
|
469
|
+
reject(new Error(`Timed out waiting for UI banner. stdout=${out} stderr=${errOut}`));
|
|
470
|
+
}, 8000);
|
|
471
|
+
child.stdout.on('data', (chunk) => {
|
|
472
|
+
out += chunk.toString('utf8');
|
|
473
|
+
const m = out.match(/http:\/\/127\.0\.0\.1:(\d+)\//);
|
|
474
|
+
if (m) {
|
|
475
|
+
clearTimeout(timer);
|
|
476
|
+
resolve({ url: m[0], port: Number(m[1]) });
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
child.stderr.on('data', (chunk) => {
|
|
480
|
+
errOut += chunk.toString('utf8');
|
|
481
|
+
});
|
|
482
|
+
child.on('exit', (code) => {
|
|
483
|
+
clearTimeout(timer);
|
|
484
|
+
reject(new Error(`UI CLI exited prematurely (${code}). stdout=${out} stderr=${errOut}`));
|
|
485
|
+
});
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
const res = await rawHttpRequest(url.port, '/api/overview');
|
|
489
|
+
assert.equal(res.status, 200);
|
|
490
|
+
const body = JSON.parse(res.body);
|
|
491
|
+
assert.equal(body.ok, true);
|
|
492
|
+
assert.equal(fs.realpathSync(body.meta.workspace_root), fs.realpathSync(wsDir));
|
|
493
|
+
|
|
494
|
+
if (process.platform !== 'win32') {
|
|
495
|
+
child.kill('SIGINT');
|
|
496
|
+
const exited = await exitPromise;
|
|
497
|
+
assert.equal(exited.code, 0);
|
|
498
|
+
} else {
|
|
499
|
+
child.kill();
|
|
500
|
+
await exitPromise;
|
|
501
|
+
}
|
|
502
|
+
});
|