@hasna/microservices 0.0.3 → 0.0.5
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/bin/index.js +63 -0
- package/bin/mcp.js +63 -0
- package/dist/index.js +63 -0
- package/microservices/microservice-ads/package.json +27 -0
- package/microservices/microservice-ads/src/cli/index.ts +605 -0
- package/microservices/microservice-ads/src/db/campaigns.ts +797 -0
- package/microservices/microservice-ads/src/db/database.ts +93 -0
- package/microservices/microservice-ads/src/db/migrations.ts +60 -0
- package/microservices/microservice-ads/src/index.ts +39 -0
- package/microservices/microservice-ads/src/mcp/index.ts +480 -0
- package/microservices/microservice-contracts/package.json +27 -0
- package/microservices/microservice-contracts/src/cli/index.ts +770 -0
- package/microservices/microservice-contracts/src/db/contracts.ts +925 -0
- package/microservices/microservice-contracts/src/db/database.ts +93 -0
- package/microservices/microservice-contracts/src/db/migrations.ts +141 -0
- package/microservices/microservice-contracts/src/index.ts +43 -0
- package/microservices/microservice-contracts/src/mcp/index.ts +617 -0
- package/microservices/microservice-domains/package.json +27 -0
- package/microservices/microservice-domains/src/cli/index.ts +691 -0
- package/microservices/microservice-domains/src/db/database.ts +93 -0
- package/microservices/microservice-domains/src/db/domains.ts +1164 -0
- package/microservices/microservice-domains/src/db/migrations.ts +60 -0
- package/microservices/microservice-domains/src/index.ts +65 -0
- package/microservices/microservice-domains/src/mcp/index.ts +536 -0
- package/microservices/microservice-hiring/package.json +27 -0
- package/microservices/microservice-hiring/src/cli/index.ts +741 -0
- package/microservices/microservice-hiring/src/db/database.ts +93 -0
- package/microservices/microservice-hiring/src/db/hiring.ts +1085 -0
- package/microservices/microservice-hiring/src/db/migrations.ts +89 -0
- package/microservices/microservice-hiring/src/index.ts +80 -0
- package/microservices/microservice-hiring/src/lib/scoring.ts +206 -0
- package/microservices/microservice-hiring/src/mcp/index.ts +709 -0
- package/microservices/microservice-payments/package.json +27 -0
- package/microservices/microservice-payments/src/cli/index.ts +609 -0
- package/microservices/microservice-payments/src/db/database.ts +93 -0
- package/microservices/microservice-payments/src/db/migrations.ts +81 -0
- package/microservices/microservice-payments/src/db/payments.ts +1204 -0
- package/microservices/microservice-payments/src/index.ts +51 -0
- package/microservices/microservice-payments/src/mcp/index.ts +683 -0
- package/microservices/microservice-payroll/package.json +27 -0
- package/microservices/microservice-payroll/src/cli/index.ts +643 -0
- package/microservices/microservice-payroll/src/db/database.ts +93 -0
- package/microservices/microservice-payroll/src/db/migrations.ts +95 -0
- package/microservices/microservice-payroll/src/db/payroll.ts +1377 -0
- package/microservices/microservice-payroll/src/index.ts +48 -0
- package/microservices/microservice-payroll/src/mcp/index.ts +666 -0
- package/microservices/microservice-shipping/package.json +27 -0
- package/microservices/microservice-shipping/src/cli/index.ts +606 -0
- package/microservices/microservice-shipping/src/db/database.ts +93 -0
- package/microservices/microservice-shipping/src/db/migrations.ts +69 -0
- package/microservices/microservice-shipping/src/db/shipping.ts +1093 -0
- package/microservices/microservice-shipping/src/index.ts +53 -0
- package/microservices/microservice-shipping/src/mcp/index.ts +533 -0
- package/microservices/microservice-social/package.json +27 -0
- package/microservices/microservice-social/src/cli/index.ts +689 -0
- package/microservices/microservice-social/src/db/database.ts +93 -0
- package/microservices/microservice-social/src/db/migrations.ts +88 -0
- package/microservices/microservice-social/src/db/social.ts +1046 -0
- package/microservices/microservice-social/src/index.ts +46 -0
- package/microservices/microservice-social/src/mcp/index.ts +655 -0
- package/microservices/microservice-subscriptions/package.json +27 -0
- package/microservices/microservice-subscriptions/src/cli/index.ts +715 -0
- package/microservices/microservice-subscriptions/src/db/database.ts +93 -0
- package/microservices/microservice-subscriptions/src/db/migrations.ts +125 -0
- package/microservices/microservice-subscriptions/src/db/subscriptions.ts +1256 -0
- package/microservices/microservice-subscriptions/src/index.ts +41 -0
- package/microservices/microservice-subscriptions/src/mcp/index.ts +631 -0
- package/package.json +1 -1
|
@@ -0,0 +1,741 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import {
|
|
6
|
+
createJob,
|
|
7
|
+
getJob,
|
|
8
|
+
listJobs,
|
|
9
|
+
closeJob,
|
|
10
|
+
createApplicant,
|
|
11
|
+
getApplicant,
|
|
12
|
+
listApplicants,
|
|
13
|
+
advanceApplicant,
|
|
14
|
+
rejectApplicant,
|
|
15
|
+
searchApplicants,
|
|
16
|
+
getPipeline,
|
|
17
|
+
getHiringStats,
|
|
18
|
+
createInterview,
|
|
19
|
+
listInterviews,
|
|
20
|
+
addInterviewFeedback,
|
|
21
|
+
bulkImportApplicants,
|
|
22
|
+
generateOffer,
|
|
23
|
+
getHiringForecast,
|
|
24
|
+
submitStructuredFeedback,
|
|
25
|
+
bulkReject,
|
|
26
|
+
getReferralStats,
|
|
27
|
+
saveJobAsTemplate,
|
|
28
|
+
createJobFromTemplate,
|
|
29
|
+
listJobTemplates,
|
|
30
|
+
} from "../db/hiring.js";
|
|
31
|
+
import { scoreApplicant, rankApplicants } from "../lib/scoring.js";
|
|
32
|
+
|
|
33
|
+
const program = new Command();
|
|
34
|
+
|
|
35
|
+
program
|
|
36
|
+
.name("microservice-hiring")
|
|
37
|
+
.description("Applicant tracking and recruitment microservice")
|
|
38
|
+
.version("0.0.1");
|
|
39
|
+
|
|
40
|
+
// --- Jobs ---
|
|
41
|
+
|
|
42
|
+
const jobCmd = program
|
|
43
|
+
.command("job")
|
|
44
|
+
.description("Job management");
|
|
45
|
+
|
|
46
|
+
jobCmd
|
|
47
|
+
.command("create")
|
|
48
|
+
.description("Create a new job posting")
|
|
49
|
+
.requiredOption("--title <title>", "Job title")
|
|
50
|
+
.option("--department <dept>", "Department")
|
|
51
|
+
.option("--location <loc>", "Location")
|
|
52
|
+
.option("--type <type>", "Job type (full-time/part-time/contract)", "full-time")
|
|
53
|
+
.option("--description <desc>", "Job description")
|
|
54
|
+
.option("--requirements <reqs>", "Comma-separated requirements")
|
|
55
|
+
.option("--salary-range <range>", "Salary range")
|
|
56
|
+
.option("--json", "Output as JSON", false)
|
|
57
|
+
.action((opts) => {
|
|
58
|
+
const job = createJob({
|
|
59
|
+
title: opts.title,
|
|
60
|
+
department: opts.department,
|
|
61
|
+
location: opts.location,
|
|
62
|
+
type: opts.type,
|
|
63
|
+
description: opts.description,
|
|
64
|
+
requirements: opts.requirements
|
|
65
|
+
? opts.requirements.split(",").map((r: string) => r.trim())
|
|
66
|
+
: undefined,
|
|
67
|
+
salary_range: opts.salaryRange,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (opts.json) {
|
|
71
|
+
console.log(JSON.stringify(job, null, 2));
|
|
72
|
+
} else {
|
|
73
|
+
console.log(`Created job: ${job.title} (${job.id})`);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
jobCmd
|
|
78
|
+
.command("list")
|
|
79
|
+
.description("List jobs")
|
|
80
|
+
.option("--status <status>", "Filter by status (open/closed/paused)")
|
|
81
|
+
.option("--department <dept>", "Filter by department")
|
|
82
|
+
.option("--type <type>", "Filter by type")
|
|
83
|
+
.option("--limit <n>", "Limit results")
|
|
84
|
+
.option("--json", "Output as JSON", false)
|
|
85
|
+
.action((opts) => {
|
|
86
|
+
const jobs = listJobs({
|
|
87
|
+
status: opts.status,
|
|
88
|
+
department: opts.department,
|
|
89
|
+
type: opts.type,
|
|
90
|
+
limit: opts.limit ? parseInt(opts.limit) : undefined,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (opts.json) {
|
|
94
|
+
console.log(JSON.stringify(jobs, null, 2));
|
|
95
|
+
} else {
|
|
96
|
+
if (jobs.length === 0) {
|
|
97
|
+
console.log("No jobs found.");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
for (const j of jobs) {
|
|
101
|
+
const dept = j.department ? ` [${j.department}]` : "";
|
|
102
|
+
console.log(` ${j.title}${dept} — ${j.status} (${j.id})`);
|
|
103
|
+
}
|
|
104
|
+
console.log(`\n${jobs.length} job(s)`);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
jobCmd
|
|
109
|
+
.command("get")
|
|
110
|
+
.description("Get a job by ID")
|
|
111
|
+
.argument("<id>", "Job ID")
|
|
112
|
+
.option("--json", "Output as JSON", false)
|
|
113
|
+
.action((id, opts) => {
|
|
114
|
+
const job = getJob(id);
|
|
115
|
+
if (!job) {
|
|
116
|
+
console.error(`Job '${id}' not found.`);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (opts.json) {
|
|
121
|
+
console.log(JSON.stringify(job, null, 2));
|
|
122
|
+
} else {
|
|
123
|
+
console.log(`${job.title}`);
|
|
124
|
+
console.log(` Status: ${job.status}`);
|
|
125
|
+
console.log(` Type: ${job.type}`);
|
|
126
|
+
if (job.department) console.log(` Department: ${job.department}`);
|
|
127
|
+
if (job.location) console.log(` Location: ${job.location}`);
|
|
128
|
+
if (job.salary_range) console.log(` Salary: ${job.salary_range}`);
|
|
129
|
+
if (job.description) console.log(` Description: ${job.description}`);
|
|
130
|
+
if (job.requirements.length) console.log(` Requirements: ${job.requirements.join(", ")}`);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
jobCmd
|
|
135
|
+
.command("close")
|
|
136
|
+
.description("Close a job posting")
|
|
137
|
+
.argument("<id>", "Job ID")
|
|
138
|
+
.option("--json", "Output as JSON", false)
|
|
139
|
+
.action((id, opts) => {
|
|
140
|
+
const job = closeJob(id);
|
|
141
|
+
if (!job) {
|
|
142
|
+
console.error(`Job '${id}' not found.`);
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (opts.json) {
|
|
147
|
+
console.log(JSON.stringify(job, null, 2));
|
|
148
|
+
} else {
|
|
149
|
+
console.log(`Closed job: ${job.title}`);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// --- Applicants ---
|
|
154
|
+
|
|
155
|
+
const applicantCmd = program
|
|
156
|
+
.command("applicant")
|
|
157
|
+
.description("Applicant management");
|
|
158
|
+
|
|
159
|
+
applicantCmd
|
|
160
|
+
.command("add")
|
|
161
|
+
.description("Add a new applicant")
|
|
162
|
+
.requiredOption("--name <name>", "Applicant name")
|
|
163
|
+
.requiredOption("--job <id>", "Job ID")
|
|
164
|
+
.option("--email <email>", "Email address")
|
|
165
|
+
.option("--phone <phone>", "Phone number")
|
|
166
|
+
.option("--resume <url>", "Resume URL")
|
|
167
|
+
.option("--source <source>", "Source (linkedin, referral, etc.)")
|
|
168
|
+
.option("--notes <notes>", "Notes")
|
|
169
|
+
.option("--json", "Output as JSON", false)
|
|
170
|
+
.action((opts) => {
|
|
171
|
+
const applicant = createApplicant({
|
|
172
|
+
name: opts.name,
|
|
173
|
+
job_id: opts.job,
|
|
174
|
+
email: opts.email,
|
|
175
|
+
phone: opts.phone,
|
|
176
|
+
resume_url: opts.resume,
|
|
177
|
+
source: opts.source,
|
|
178
|
+
notes: opts.notes,
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
if (opts.json) {
|
|
182
|
+
console.log(JSON.stringify(applicant, null, 2));
|
|
183
|
+
} else {
|
|
184
|
+
console.log(`Added applicant: ${applicant.name} (${applicant.id})`);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
applicantCmd
|
|
189
|
+
.command("list")
|
|
190
|
+
.description("List applicants")
|
|
191
|
+
.option("--job <id>", "Filter by job ID")
|
|
192
|
+
.option("--status <status>", "Filter by status")
|
|
193
|
+
.option("--source <source>", "Filter by source")
|
|
194
|
+
.option("--limit <n>", "Limit results")
|
|
195
|
+
.option("--json", "Output as JSON", false)
|
|
196
|
+
.action((opts) => {
|
|
197
|
+
const applicants = listApplicants({
|
|
198
|
+
job_id: opts.job,
|
|
199
|
+
status: opts.status,
|
|
200
|
+
source: opts.source,
|
|
201
|
+
limit: opts.limit ? parseInt(opts.limit) : undefined,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
if (opts.json) {
|
|
205
|
+
console.log(JSON.stringify(applicants, null, 2));
|
|
206
|
+
} else {
|
|
207
|
+
if (applicants.length === 0) {
|
|
208
|
+
console.log("No applicants found.");
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
for (const a of applicants) {
|
|
212
|
+
const email = a.email ? ` <${a.email}>` : "";
|
|
213
|
+
console.log(` ${a.name}${email} — ${a.status} (${a.id})`);
|
|
214
|
+
}
|
|
215
|
+
console.log(`\n${applicants.length} applicant(s)`);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
applicantCmd
|
|
220
|
+
.command("get")
|
|
221
|
+
.description("Get an applicant by ID")
|
|
222
|
+
.argument("<id>", "Applicant ID")
|
|
223
|
+
.option("--json", "Output as JSON", false)
|
|
224
|
+
.action((id, opts) => {
|
|
225
|
+
const applicant = getApplicant(id);
|
|
226
|
+
if (!applicant) {
|
|
227
|
+
console.error(`Applicant '${id}' not found.`);
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (opts.json) {
|
|
232
|
+
console.log(JSON.stringify(applicant, null, 2));
|
|
233
|
+
} else {
|
|
234
|
+
console.log(`${applicant.name}`);
|
|
235
|
+
console.log(` Status: ${applicant.status}`);
|
|
236
|
+
if (applicant.email) console.log(` Email: ${applicant.email}`);
|
|
237
|
+
if (applicant.phone) console.log(` Phone: ${applicant.phone}`);
|
|
238
|
+
if (applicant.source) console.log(` Source: ${applicant.source}`);
|
|
239
|
+
if (applicant.rating) console.log(` Rating: ${applicant.rating}`);
|
|
240
|
+
if (applicant.notes) console.log(` Notes: ${applicant.notes}`);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
applicantCmd
|
|
245
|
+
.command("advance")
|
|
246
|
+
.description("Advance an applicant to a new status")
|
|
247
|
+
.argument("<id>", "Applicant ID")
|
|
248
|
+
.requiredOption("--status <status>", "New status (screening/interviewing/offered/hired)")
|
|
249
|
+
.option("--json", "Output as JSON", false)
|
|
250
|
+
.action((id, opts) => {
|
|
251
|
+
const applicant = advanceApplicant(id, opts.status);
|
|
252
|
+
if (!applicant) {
|
|
253
|
+
console.error(`Applicant '${id}' not found.`);
|
|
254
|
+
process.exit(1);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (opts.json) {
|
|
258
|
+
console.log(JSON.stringify(applicant, null, 2));
|
|
259
|
+
} else {
|
|
260
|
+
console.log(`Advanced ${applicant.name} to ${applicant.status}`);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
applicantCmd
|
|
265
|
+
.command("reject")
|
|
266
|
+
.description("Reject an applicant")
|
|
267
|
+
.argument("<id>", "Applicant ID")
|
|
268
|
+
.option("--reason <reason>", "Rejection reason")
|
|
269
|
+
.option("--json", "Output as JSON", false)
|
|
270
|
+
.action((id, opts) => {
|
|
271
|
+
const applicant = rejectApplicant(id, opts.reason);
|
|
272
|
+
if (!applicant) {
|
|
273
|
+
console.error(`Applicant '${id}' not found.`);
|
|
274
|
+
process.exit(1);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (opts.json) {
|
|
278
|
+
console.log(JSON.stringify(applicant, null, 2));
|
|
279
|
+
} else {
|
|
280
|
+
console.log(`Rejected ${applicant.name}`);
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
applicantCmd
|
|
285
|
+
.command("search")
|
|
286
|
+
.description("Search applicants")
|
|
287
|
+
.argument("<query>", "Search term")
|
|
288
|
+
.option("--json", "Output as JSON", false)
|
|
289
|
+
.action((query, opts) => {
|
|
290
|
+
const results = searchApplicants(query);
|
|
291
|
+
|
|
292
|
+
if (opts.json) {
|
|
293
|
+
console.log(JSON.stringify(results, null, 2));
|
|
294
|
+
} else {
|
|
295
|
+
if (results.length === 0) {
|
|
296
|
+
console.log(`No applicants matching "${query}".`);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
for (const a of results) {
|
|
300
|
+
console.log(` ${a.name} ${a.email ? `<${a.email}>` : ""} — ${a.status}`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
// --- Bulk Import ---
|
|
306
|
+
|
|
307
|
+
applicantCmd
|
|
308
|
+
.command("bulk-import")
|
|
309
|
+
.description("Bulk import applicants from a CSV file")
|
|
310
|
+
.requiredOption("--file <path>", "Path to CSV file (name,email,phone,job_id,source,resume_url)")
|
|
311
|
+
.option("--json", "Output as JSON", false)
|
|
312
|
+
.action((opts) => {
|
|
313
|
+
const csvData = readFileSync(opts.file, "utf-8");
|
|
314
|
+
const result = bulkImportApplicants(csvData);
|
|
315
|
+
|
|
316
|
+
if (opts.json) {
|
|
317
|
+
console.log(JSON.stringify(result, null, 2));
|
|
318
|
+
} else {
|
|
319
|
+
console.log(`Imported: ${result.imported}`);
|
|
320
|
+
console.log(`Skipped: ${result.skipped}`);
|
|
321
|
+
if (result.errors.length > 0) {
|
|
322
|
+
console.log("Errors:");
|
|
323
|
+
for (const e of result.errors) {
|
|
324
|
+
console.log(` - ${e}`);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
// --- AI Scoring ---
|
|
331
|
+
|
|
332
|
+
applicantCmd
|
|
333
|
+
.command("score")
|
|
334
|
+
.description("AI-score an applicant against job requirements")
|
|
335
|
+
.argument("<id>", "Applicant ID")
|
|
336
|
+
.option("--json", "Output as JSON", false)
|
|
337
|
+
.action(async (id, opts) => {
|
|
338
|
+
try {
|
|
339
|
+
const score = await scoreApplicant(id);
|
|
340
|
+
|
|
341
|
+
if (opts.json) {
|
|
342
|
+
console.log(JSON.stringify(score, null, 2));
|
|
343
|
+
} else {
|
|
344
|
+
console.log(`Match: ${score.match_pct}%`);
|
|
345
|
+
console.log(`Recommendation: ${score.recommendation}`);
|
|
346
|
+
if (score.strengths.length) console.log(`Strengths: ${score.strengths.join(", ")}`);
|
|
347
|
+
if (score.gaps.length) console.log(`Gaps: ${score.gaps.join(", ")}`);
|
|
348
|
+
}
|
|
349
|
+
} catch (err) {
|
|
350
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
351
|
+
process.exit(1);
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
// --- AI Bulk Ranking ---
|
|
356
|
+
|
|
357
|
+
applicantCmd
|
|
358
|
+
.command("rank")
|
|
359
|
+
.description("AI-rank all applicants for a job by fit score")
|
|
360
|
+
.requiredOption("--job <id>", "Job ID")
|
|
361
|
+
.option("--json", "Output as JSON", false)
|
|
362
|
+
.action(async (opts) => {
|
|
363
|
+
try {
|
|
364
|
+
const ranked = await rankApplicants(opts.job);
|
|
365
|
+
|
|
366
|
+
if (opts.json) {
|
|
367
|
+
console.log(JSON.stringify(ranked, null, 2));
|
|
368
|
+
} else {
|
|
369
|
+
if (ranked.length === 0) {
|
|
370
|
+
console.log("No applicants to rank.");
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
console.log("Ranking:");
|
|
374
|
+
for (let i = 0; i < ranked.length; i++) {
|
|
375
|
+
const { applicant, score } = ranked[i];
|
|
376
|
+
console.log(` ${i + 1}. ${applicant.name} — ${score.match_pct}% (${score.recommendation})`);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
} catch (err) {
|
|
380
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
381
|
+
process.exit(1);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
// --- Offer Letter ---
|
|
386
|
+
|
|
387
|
+
applicantCmd
|
|
388
|
+
.command("offer")
|
|
389
|
+
.description("Generate a Markdown offer letter")
|
|
390
|
+
.argument("<id>", "Applicant ID")
|
|
391
|
+
.requiredOption("--salary <amount>", "Annual salary")
|
|
392
|
+
.requiredOption("--start-date <date>", "Start date (YYYY-MM-DD)")
|
|
393
|
+
.option("--title <title>", "Position title override")
|
|
394
|
+
.option("--department <dept>", "Department override")
|
|
395
|
+
.option("--benefits <text>", "Benefits description")
|
|
396
|
+
.option("--equity <text>", "Equity details")
|
|
397
|
+
.option("--signing-bonus <amount>", "Signing bonus")
|
|
398
|
+
.option("--json", "Output as JSON", false)
|
|
399
|
+
.action((id, opts) => {
|
|
400
|
+
try {
|
|
401
|
+
const letter = generateOffer(id, {
|
|
402
|
+
salary: parseInt(opts.salary),
|
|
403
|
+
start_date: opts.startDate,
|
|
404
|
+
position_title: opts.title,
|
|
405
|
+
department: opts.department,
|
|
406
|
+
benefits: opts.benefits,
|
|
407
|
+
equity: opts.equity,
|
|
408
|
+
signing_bonus: opts.signingBonus ? parseInt(opts.signingBonus) : undefined,
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
if (opts.json) {
|
|
412
|
+
console.log(JSON.stringify({ offer_letter: letter }, null, 2));
|
|
413
|
+
} else {
|
|
414
|
+
console.log(letter);
|
|
415
|
+
}
|
|
416
|
+
} catch (err) {
|
|
417
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
418
|
+
process.exit(1);
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
// --- Bulk Rejection ---
|
|
423
|
+
|
|
424
|
+
applicantCmd
|
|
425
|
+
.command("reject-batch")
|
|
426
|
+
.description("Bulk reject applicants for a job by status")
|
|
427
|
+
.requiredOption("--job <id>", "Job ID")
|
|
428
|
+
.requiredOption("--status <status>", "Status to reject (applied/screening/etc.)")
|
|
429
|
+
.option("--reason <reason>", "Rejection reason")
|
|
430
|
+
.option("--json", "Output as JSON", false)
|
|
431
|
+
.action((opts) => {
|
|
432
|
+
const result = bulkReject(opts.job, opts.status, opts.reason);
|
|
433
|
+
|
|
434
|
+
if (opts.json) {
|
|
435
|
+
console.log(JSON.stringify(result, null, 2));
|
|
436
|
+
} else {
|
|
437
|
+
console.log(`Rejected ${result.rejected} applicant(s)`);
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
// --- Interviews ---
|
|
442
|
+
|
|
443
|
+
const interviewCmd = program
|
|
444
|
+
.command("interview")
|
|
445
|
+
.description("Interview management");
|
|
446
|
+
|
|
447
|
+
interviewCmd
|
|
448
|
+
.command("schedule")
|
|
449
|
+
.description("Schedule an interview")
|
|
450
|
+
.requiredOption("--applicant <id>", "Applicant ID")
|
|
451
|
+
.option("--interviewer <name>", "Interviewer name")
|
|
452
|
+
.option("--at <datetime>", "Scheduled datetime (ISO 8601)")
|
|
453
|
+
.option("--duration <min>", "Duration in minutes")
|
|
454
|
+
.option("--type <type>", "Interview type (phone/video/onsite)", "phone")
|
|
455
|
+
.option("--json", "Output as JSON", false)
|
|
456
|
+
.action((opts) => {
|
|
457
|
+
const interview = createInterview({
|
|
458
|
+
applicant_id: opts.applicant,
|
|
459
|
+
interviewer: opts.interviewer,
|
|
460
|
+
scheduled_at: opts.at,
|
|
461
|
+
duration_min: opts.duration ? parseInt(opts.duration) : undefined,
|
|
462
|
+
type: opts.type,
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
if (opts.json) {
|
|
466
|
+
console.log(JSON.stringify(interview, null, 2));
|
|
467
|
+
} else {
|
|
468
|
+
console.log(`Scheduled interview (${interview.id})`);
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
interviewCmd
|
|
473
|
+
.command("list")
|
|
474
|
+
.description("List interviews")
|
|
475
|
+
.option("--applicant <id>", "Filter by applicant ID")
|
|
476
|
+
.option("--status <status>", "Filter by status")
|
|
477
|
+
.option("--type <type>", "Filter by type")
|
|
478
|
+
.option("--limit <n>", "Limit results")
|
|
479
|
+
.option("--json", "Output as JSON", false)
|
|
480
|
+
.action((opts) => {
|
|
481
|
+
const interviews = listInterviews({
|
|
482
|
+
applicant_id: opts.applicant,
|
|
483
|
+
status: opts.status,
|
|
484
|
+
type: opts.type,
|
|
485
|
+
limit: opts.limit ? parseInt(opts.limit) : undefined,
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
if (opts.json) {
|
|
489
|
+
console.log(JSON.stringify(interviews, null, 2));
|
|
490
|
+
} else {
|
|
491
|
+
if (interviews.length === 0) {
|
|
492
|
+
console.log("No interviews found.");
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
for (const i of interviews) {
|
|
496
|
+
const when = i.scheduled_at || "TBD";
|
|
497
|
+
const who = i.interviewer || "TBD";
|
|
498
|
+
console.log(` ${i.type} with ${who} @ ${when} — ${i.status} (${i.id})`);
|
|
499
|
+
}
|
|
500
|
+
console.log(`\n${interviews.length} interview(s)`);
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
interviewCmd
|
|
505
|
+
.command("feedback")
|
|
506
|
+
.description("Add feedback to an interview (supports structured scoring dimensions)")
|
|
507
|
+
.argument("<id>", "Interview ID")
|
|
508
|
+
.option("--feedback <text>", "Feedback text")
|
|
509
|
+
.option("--rating <n>", "Overall rating (1-5)")
|
|
510
|
+
.option("--technical <n>", "Technical score (1-5)")
|
|
511
|
+
.option("--communication <n>", "Communication score (1-5)")
|
|
512
|
+
.option("--culture-fit <n>", "Culture fit score (1-5)")
|
|
513
|
+
.option("--problem-solving <n>", "Problem solving score (1-5)")
|
|
514
|
+
.option("--leadership <n>", "Leadership score (1-5)")
|
|
515
|
+
.option("--json", "Output as JSON", false)
|
|
516
|
+
.action((id, opts) => {
|
|
517
|
+
const hasStructured = opts.technical || opts.communication || opts.cultureFit ||
|
|
518
|
+
opts.problemSolving || opts.leadership;
|
|
519
|
+
|
|
520
|
+
let interview;
|
|
521
|
+
if (hasStructured) {
|
|
522
|
+
interview = submitStructuredFeedback(
|
|
523
|
+
id,
|
|
524
|
+
{
|
|
525
|
+
technical: opts.technical ? parseInt(opts.technical) : undefined,
|
|
526
|
+
communication: opts.communication ? parseInt(opts.communication) : undefined,
|
|
527
|
+
culture_fit: opts.cultureFit ? parseInt(opts.cultureFit) : undefined,
|
|
528
|
+
problem_solving: opts.problemSolving ? parseInt(opts.problemSolving) : undefined,
|
|
529
|
+
leadership: opts.leadership ? parseInt(opts.leadership) : undefined,
|
|
530
|
+
overall: opts.rating ? parseInt(opts.rating) : undefined,
|
|
531
|
+
},
|
|
532
|
+
opts.feedback
|
|
533
|
+
);
|
|
534
|
+
} else {
|
|
535
|
+
if (!opts.feedback) {
|
|
536
|
+
console.error("Either --feedback or structured scores (--technical, --communication, etc.) are required.");
|
|
537
|
+
process.exit(1);
|
|
538
|
+
}
|
|
539
|
+
interview = addInterviewFeedback(
|
|
540
|
+
id,
|
|
541
|
+
opts.feedback,
|
|
542
|
+
opts.rating ? parseInt(opts.rating) : undefined
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (!interview) {
|
|
547
|
+
console.error(`Interview '${id}' not found.`);
|
|
548
|
+
process.exit(1);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
if (opts.json) {
|
|
552
|
+
console.log(JSON.stringify(interview, null, 2));
|
|
553
|
+
} else {
|
|
554
|
+
console.log(`Added feedback to interview ${id}`);
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
// --- Pipeline & Stats ---
|
|
559
|
+
|
|
560
|
+
program
|
|
561
|
+
.command("pipeline")
|
|
562
|
+
.description("Show hiring pipeline for a job")
|
|
563
|
+
.argument("<job-id>", "Job ID")
|
|
564
|
+
.option("--json", "Output as JSON", false)
|
|
565
|
+
.action((jobId, opts) => {
|
|
566
|
+
const pipeline = getPipeline(jobId);
|
|
567
|
+
|
|
568
|
+
if (opts.json) {
|
|
569
|
+
console.log(JSON.stringify(pipeline, null, 2));
|
|
570
|
+
} else {
|
|
571
|
+
if (pipeline.length === 0) {
|
|
572
|
+
console.log("No applicants in pipeline.");
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
console.log("Pipeline:");
|
|
576
|
+
for (const p of pipeline) {
|
|
577
|
+
const bar = "#".repeat(p.count);
|
|
578
|
+
console.log(` ${p.status.padEnd(14)} ${bar} (${p.count})`);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
program
|
|
584
|
+
.command("stats")
|
|
585
|
+
.description("Show hiring statistics")
|
|
586
|
+
.option("--json", "Output as JSON", false)
|
|
587
|
+
.action((opts) => {
|
|
588
|
+
const stats = getHiringStats();
|
|
589
|
+
|
|
590
|
+
if (opts.json) {
|
|
591
|
+
console.log(JSON.stringify(stats, null, 2));
|
|
592
|
+
} else {
|
|
593
|
+
console.log("Hiring Stats:");
|
|
594
|
+
console.log(` Jobs: ${stats.total_jobs} total, ${stats.open_jobs} open`);
|
|
595
|
+
console.log(` Applicants: ${stats.total_applicants}`);
|
|
596
|
+
console.log(` Interviews: ${stats.total_interviews}`);
|
|
597
|
+
if (stats.avg_rating) console.log(` Avg Rating: ${stats.avg_rating}`);
|
|
598
|
+
if (stats.applicants_by_status.length) {
|
|
599
|
+
console.log(" By Status:");
|
|
600
|
+
for (const s of stats.applicants_by_status) {
|
|
601
|
+
console.log(` ${s.status}: ${s.count}`);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
// --- Referral Stats ---
|
|
608
|
+
|
|
609
|
+
const statsCmd = program
|
|
610
|
+
.command("stats-referrals")
|
|
611
|
+
.description("Show referral/source conversion rates")
|
|
612
|
+
.option("--json", "Output as JSON", false)
|
|
613
|
+
.action((opts) => {
|
|
614
|
+
const stats = getReferralStats();
|
|
615
|
+
|
|
616
|
+
if (opts.json) {
|
|
617
|
+
console.log(JSON.stringify(stats, null, 2));
|
|
618
|
+
} else {
|
|
619
|
+
if (stats.length === 0) {
|
|
620
|
+
console.log("No applicant source data.");
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
console.log("Referral Stats:");
|
|
624
|
+
for (const s of stats) {
|
|
625
|
+
console.log(` ${s.source}: ${s.total} total, ${s.hired} hired, ${s.conversion_rate}% conversion`);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
// --- Forecast ---
|
|
631
|
+
|
|
632
|
+
program
|
|
633
|
+
.command("forecast")
|
|
634
|
+
.description("Estimate days-to-fill based on pipeline velocity")
|
|
635
|
+
.argument("<job-id>", "Job ID")
|
|
636
|
+
.option("--json", "Output as JSON", false)
|
|
637
|
+
.action((jobId, opts) => {
|
|
638
|
+
try {
|
|
639
|
+
const forecast = getHiringForecast(jobId);
|
|
640
|
+
|
|
641
|
+
if (opts.json) {
|
|
642
|
+
console.log(JSON.stringify(forecast, null, 2));
|
|
643
|
+
} else {
|
|
644
|
+
console.log(`Forecast for: ${forecast.job_title}`);
|
|
645
|
+
console.log(` Total applicants: ${forecast.total_applicants}`);
|
|
646
|
+
console.log(` Estimated days to fill: ${forecast.estimated_days_to_fill ?? "N/A"}`);
|
|
647
|
+
|
|
648
|
+
if (Object.keys(forecast.avg_days_per_stage).length) {
|
|
649
|
+
console.log(" Avg days per transition:");
|
|
650
|
+
for (const [stage, days] of Object.entries(forecast.avg_days_per_stage)) {
|
|
651
|
+
console.log(` ${stage}: ${days} days`);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
if (Object.keys(forecast.conversion_rates).length) {
|
|
656
|
+
console.log(" Conversion rates:");
|
|
657
|
+
for (const [stage, rate] of Object.entries(forecast.conversion_rates)) {
|
|
658
|
+
console.log(` ${stage}: ${rate}%`);
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
} catch (err) {
|
|
663
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
664
|
+
process.exit(1);
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
// --- Job Templates ---
|
|
669
|
+
|
|
670
|
+
jobCmd
|
|
671
|
+
.command("save-template")
|
|
672
|
+
.description("Save a job as a reusable template")
|
|
673
|
+
.argument("<id>", "Job ID")
|
|
674
|
+
.requiredOption("--name <name>", "Template name")
|
|
675
|
+
.option("--json", "Output as JSON", false)
|
|
676
|
+
.action((id, opts) => {
|
|
677
|
+
try {
|
|
678
|
+
const template = saveJobAsTemplate(id, opts.name);
|
|
679
|
+
|
|
680
|
+
if (opts.json) {
|
|
681
|
+
console.log(JSON.stringify(template, null, 2));
|
|
682
|
+
} else {
|
|
683
|
+
console.log(`Saved template: ${template.name} (${template.id})`);
|
|
684
|
+
}
|
|
685
|
+
} catch (err) {
|
|
686
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
687
|
+
process.exit(1);
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
jobCmd
|
|
692
|
+
.command("from-template")
|
|
693
|
+
.description("Create a job from a template")
|
|
694
|
+
.requiredOption("--template <name>", "Template name")
|
|
695
|
+
.option("--title <title>", "Override title")
|
|
696
|
+
.option("--department <dept>", "Override department")
|
|
697
|
+
.option("--location <loc>", "Override location")
|
|
698
|
+
.option("--salary-range <range>", "Override salary range")
|
|
699
|
+
.option("--json", "Output as JSON", false)
|
|
700
|
+
.action((opts) => {
|
|
701
|
+
try {
|
|
702
|
+
const job = createJobFromTemplate(opts.template, {
|
|
703
|
+
title: opts.title,
|
|
704
|
+
department: opts.department,
|
|
705
|
+
location: opts.location,
|
|
706
|
+
salary_range: opts.salaryRange,
|
|
707
|
+
});
|
|
708
|
+
|
|
709
|
+
if (opts.json) {
|
|
710
|
+
console.log(JSON.stringify(job, null, 2));
|
|
711
|
+
} else {
|
|
712
|
+
console.log(`Created job from template: ${job.title} (${job.id})`);
|
|
713
|
+
}
|
|
714
|
+
} catch (err) {
|
|
715
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
716
|
+
process.exit(1);
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
jobCmd
|
|
721
|
+
.command("templates")
|
|
722
|
+
.description("List all job templates")
|
|
723
|
+
.option("--json", "Output as JSON", false)
|
|
724
|
+
.action((opts) => {
|
|
725
|
+
const templates = listJobTemplates();
|
|
726
|
+
|
|
727
|
+
if (opts.json) {
|
|
728
|
+
console.log(JSON.stringify(templates, null, 2));
|
|
729
|
+
} else {
|
|
730
|
+
if (templates.length === 0) {
|
|
731
|
+
console.log("No templates found.");
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
for (const t of templates) {
|
|
735
|
+
console.log(` ${t.name} — ${t.title} (${t.id})`);
|
|
736
|
+
}
|
|
737
|
+
console.log(`\n${templates.length} template(s)`);
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
program.parse(process.argv);
|