@sortlist/cli 0.60.0 → 0.62.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/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/sortlist-cli/SKILL.md +139 -561
- package/skills/sortlist-cli/references/atlas.md +197 -0
- package/skills/sortlist-cli/references/billing-and-permissions.md +236 -0
- package/skills/sortlist-cli/references/identity-and-accounts.md +118 -0
- package/skills/sortlist-cli/references/outreach.md +126 -0
- package/skills/sortlist-cli/references/signals.md +104 -0
- package/skills/sortlist-cli/scripts/quote-reveals.mjs +182 -0
- package/skills/sortlist-go-to-market/SKILL.md +73 -233
- package/skills/sortlist-go-to-market/references/agency-briefing.md +22 -0
- package/skills/sortlist-go-to-market/references/campaigns.md +114 -0
- package/skills/sortlist-go-to-market/references/context-and-brief.md +92 -0
- package/skills/sortlist-go-to-market/references/prospect-list.md +115 -0
- package/skills/sortlist-go-to-market/references/search-state.md +87 -0
- package/skills/sortlist-go-to-market/references/sourcing.md +194 -0
- package/skills/sortlist-go-to-market/scripts/render-prospect-list.mjs +157 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Deliver a usable prospect list
|
|
2
|
+
|
|
3
|
+
Read this when the user wants a substantial prospect universe, a reusable list or export, or supplies
|
|
4
|
+
an example to reproduce. Use [sourcing](sourcing.md) for account and role qualification and
|
|
5
|
+
`sortlist-cli` for execution, costs and recovery. The desired result is something the customer can
|
|
6
|
+
use, inspect and refine in chat without operating a terminal.
|
|
7
|
+
|
|
8
|
+
## Set a useful delivery target
|
|
9
|
+
|
|
10
|
+
Reuse the brief and any supplied example. Infer reversible presentation choices from that example,
|
|
11
|
+
including language, grouping, filters and export format. State a material assumption briefly and
|
|
12
|
+
start. Ask only about choices that change the target, the cost or an irreversible action. Do not
|
|
13
|
+
ask a customer to design semantic queries, choose schema fields or interpret a cursor.
|
|
14
|
+
|
|
15
|
+
Translate the request into a working target: eligible accounts and territory, useful roles, requested
|
|
16
|
+
scale, exclusions, permitted contact details and intended final format. Preserve it across follow-ups.
|
|
17
|
+
Where no volume is specified, choose a useful first delivery proportional to the task and call it
|
|
18
|
+
that; do not imply a five-row sample exhausts a territory. A historical reference's row count is a
|
|
19
|
+
benchmark, not permission to buy that many contact details or a guaranteed present-day yield.
|
|
20
|
+
|
|
21
|
+
## Collect for the promised result
|
|
22
|
+
|
|
23
|
+
Maintain one task dataset with stable organization/contact ids, the retained facts, qualification
|
|
24
|
+
decisions, source response or supplied file, retrieval date, and the search state needed to continue.
|
|
25
|
+
Keep search credentials and secrets out of it. Preserve the user's exclusions in collection and
|
|
26
|
+
exports; if phone information is forbidden, omit phone fields entirely rather than hiding them only
|
|
27
|
+
in the visible table.
|
|
28
|
+
|
|
29
|
+
Separate three quantities: accounts assessed, accounts retained, and relevant contacts retained.
|
|
30
|
+
Account coverage without a named contact can still be useful, but do not count a locked identity as
|
|
31
|
+
a named decision maker. Deduplicate across pages and company aliases before computing totals. A
|
|
32
|
+
record returned by two searches is one candidate; distinct ids with uncertain identity need an
|
|
33
|
+
explicit ambiguity, not a fabricated merge.
|
|
34
|
+
|
|
35
|
+
Continue available pages and sensible account/role checks toward the delivery target within the
|
|
36
|
+
authorized scope. A CLI page-size limit calls for pagination, not a permanent tiny shortlist. Respect
|
|
37
|
+
actual search caps and expiry; partition a larger search only with meaningful, documented criteria
|
|
38
|
+
that preserve scope, and reconcile duplicates and gaps. Never imply a snapshot is exhaustive when
|
|
39
|
+
the API limit or an unresolved page prevents that conclusion.
|
|
40
|
+
|
|
41
|
+
Reuse already available, authorized identity and reach data. When an otherwise useful field is
|
|
42
|
+
locked, say what is missing and prepare the smallest bounded unlock decision if needed. Missing
|
|
43
|
+
permission for one dimension should not block delivery of the usable company/role list. A requested
|
|
44
|
+
HTML or CSV file does not authorize new reveals, lookup dimensions or outreach.
|
|
45
|
+
|
|
46
|
+
## Make prioritization commercially useful
|
|
47
|
+
|
|
48
|
+
Rank accounts by facts relevant to the customer's offer, using a short, intelligible rule. Prefer
|
|
49
|
+
labels such as "Start here" and "Worth checking" to an unexplained numerical score. If the user
|
|
50
|
+
wants A/B/C or a score, give its meaning and retain the supporting evidence with each row.
|
|
51
|
+
|
|
52
|
+
For example, physical-site security may make an observed industrial site and a facilities role
|
|
53
|
+
useful. That supports a reason to approach the account, not a claim that its alarm is obsolete,
|
|
54
|
+
that it has an active project or that the contact owns a budget. Sector, size or growth can support
|
|
55
|
+
a hypothesis; do not turn them into a fabricated buying signal. Distinguish priority of the company
|
|
56
|
+
from confidence in the person's exact responsibility.
|
|
57
|
+
|
|
58
|
+
Retain actual titles and explain their useful function. Do not let broad substring matches turn a
|
|
59
|
+
creative director into an IT buyer or a generic director into a security specialist. Show uncertainty
|
|
60
|
+
in short, specific language that helps the customer act, such as "Local site confirmed; central
|
|
61
|
+
facilities responsibility to check". Keep clearly unsuitable contacts out of the final qualified list.
|
|
62
|
+
|
|
63
|
+
## Deliver files the customer can use
|
|
64
|
+
|
|
65
|
+
Match the supplied example or requested format where the host supports it. For a substantial list,
|
|
66
|
+
provide a downloadable CSV and a readable view with the full retained dataset when those capabilities
|
|
67
|
+
are available. An interactive HTML view is useful when the host can return and open it; it is not an
|
|
68
|
+
assumed native ChatGPT feature. If attachments or rendering are unavailable, give the best supported
|
|
69
|
+
view and state the exact delivery limitation. Do not send a local filesystem path as a usable client
|
|
70
|
+
download in a cloud chat or claim a file exists before creating it.
|
|
71
|
+
|
|
72
|
+
Choose business-facing columns from available evidence: company, location/site, activity, size,
|
|
73
|
+
priority and reason, contact and actual role, relevant available channel, and a short check remaining.
|
|
74
|
+
Put source, retrieval date, verification status/date where returned, and coverage detail in a
|
|
75
|
+
secondary view or companion metadata instead of overwhelming the primary list. Retrieval date is
|
|
76
|
+
not the date of employment verification. A populated email is not a verified email unless the source
|
|
77
|
+
provides that status, and a current-looking title is not proof of current employment.
|
|
78
|
+
Keep each primary reason short and specific. Put a shared limitation once in the scope summary;
|
|
79
|
+
retain row-specific uncertainty where it changes the customer's choice. Repeating a full audit
|
|
80
|
+
paragraph on every row makes a correct list hard to use.
|
|
81
|
+
|
|
82
|
+
When Node and file delivery are available, the bundled
|
|
83
|
+
[phone-free list renderer](../scripts/render-prospect-list.mjs) creates a consistent HTML view, CSV
|
|
84
|
+
and reusable state from a normalized JSON dataset. Read its `--help` for the accepted schema, then
|
|
85
|
+
run `node <skill>/scripts/render-prospect-list.mjs --input <normalized.json> --out <directory>`.
|
|
86
|
+
Qualify the source records and populate evidence before rendering; the script does not perform
|
|
87
|
+
Atlas searches or decide buyer fit. Its allowlist intentionally omits phone information. Use another
|
|
88
|
+
supported artifact path when the requested fields or host capabilities do not fit this helper.
|
|
89
|
+
|
|
90
|
+
For an interactive list, support the useful actions from the example, such as search, location,
|
|
91
|
+
sector and priority filters, sorting, and export of the selection. Display the counts after filtering
|
|
92
|
+
and keep the export tied to that same selection. If "contacts with email" is a contact filter, do not
|
|
93
|
+
export the account's other contacts as if they also satisfy it. Missing email must not remove an
|
|
94
|
+
otherwise useful account unless the user explicitly requires that coverage.
|
|
95
|
+
|
|
96
|
+
Use one underlying dataset for the view and CSV, with consistent rows, ids, priorities and counts.
|
|
97
|
+
Before handing it over, open or validate the actual artifact: reconcile totals and duplicates, check
|
|
98
|
+
the requested filters and links, and verify a filtered export and excluded fields. Escape untrusted
|
|
99
|
+
data in generated files and protect spreadsheet cells from formula execution. Keep private records
|
|
100
|
+
inside the user's authorized delivery destination; generating a file does not authorize publication.
|
|
101
|
+
|
|
102
|
+
## Make the next turn easy
|
|
103
|
+
|
|
104
|
+
Lead in chat with the useful outcome, a few representative accounts and the file or view. State the
|
|
105
|
+
actual coverage and any material gap in ordinary language. Reserve technical diagnostics for a
|
|
106
|
+
technical user or a blocker they need to resolve. For a bounded search with no new customer reveals,
|
|
107
|
+
report that observed fact without claiming all provider work was free.
|
|
108
|
+
|
|
109
|
+
Support follow-ups such as "around this town", "only the top priorities", "exclude my existing
|
|
110
|
+
clients" or "give me the facilities managers" as refinements of the existing task dataset. Reuse the
|
|
111
|
+
original brief and authorization, preserve exclusions, and recalculate the view, export and counts
|
|
112
|
+
together. Apply a simple re-sort or filter locally when the needed data is already present. Explain
|
|
113
|
+
when a refinement actually needs more collection or a paid detail before doing that added work.
|
|
114
|
+
Do not start a new onboarding interview, repurchase owned data or silently broaden territory to make
|
|
115
|
+
the revised list look fuller.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Preserve search state across pages and turns
|
|
2
|
+
|
|
3
|
+
Use a small structured journal for multi-account collection, pagination, recovery or later
|
|
4
|
+
refinement. It complements the customer-facing delivery dataset and its `state.json`; it is not
|
|
5
|
+
another source of customer facts. Keep it in the authorized task workspace, for example as
|
|
6
|
+
`search-state.json`, or in equivalent host-supported task state. Do not promise persistence the
|
|
7
|
+
host cannot provide.
|
|
8
|
+
|
|
9
|
+
## Minimum useful state
|
|
10
|
+
|
|
11
|
+
| Group | Retain |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| Brief | Requested offer, account set or discovery criteria, territory, useful roles, quota, deliverable, exclusions and their provenance. Distinguish facts, assumptions and unresolved contradictions. |
|
|
14
|
+
| Context | Acting company, caller kind and environment actually checked; source and time of that check. Do not infer the business being prospected from the payer. |
|
|
15
|
+
| Provenance | Source reference, kind, retrieval date and the fact it supports. Link to the captured response or supplied artifact instead of duplicating its entire contents. Keep source verification dates distinct from retrieval dates. |
|
|
16
|
+
| Selection | Stable organization/contact IDs, account aliases with their evidence, retained or rejected status, reason, and the scope of any existing authorization. |
|
|
17
|
+
| Searches | Operation, external ID, company, filters, sort, selected fields, dimensions, page arguments, last returned status, exit code, cursor, remaining pages and source reference. |
|
|
18
|
+
| Progress | Accounts assessed, relevant coverage per account, fallbacks and gaps, pending requests, caps reached and the next useful collection step. Derive counts from distinct retained IDs. |
|
|
19
|
+
|
|
20
|
+
A compact shape can look like this; adapt it to the task rather than filling irrelevant fields:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"version": 1,
|
|
25
|
+
"brief": {
|
|
26
|
+
"offer": "Physical-site alarm installation",
|
|
27
|
+
"territory": "Supplied target province",
|
|
28
|
+
"roles": ["facilities", "maintenance", "prevention"],
|
|
29
|
+
"targetPerAccount": 1,
|
|
30
|
+
"deliverable": "prospect list",
|
|
31
|
+
"exclusions": ["phone access", "outreach", "new paid dimensions"],
|
|
32
|
+
"sourceRefs": ["brief-1"],
|
|
33
|
+
"assumptions": []
|
|
34
|
+
},
|
|
35
|
+
"context": {"company": "example-company", "callerKind": "person", "environment": "production", "sourceRef": "context-1"},
|
|
36
|
+
"provenance": [
|
|
37
|
+
{"id": "brief-1", "kind": "user-request", "source": "current task", "fact": "Target and exclusions supplied by user"},
|
|
38
|
+
{"id": "context-1", "kind": "cli-response", "source": "captured whoami/config response"},
|
|
39
|
+
{"id": "page-1", "kind": "cli-response", "source": "captured completed response", "retrievedAt": "2026-11-10T10:00:00Z"}
|
|
40
|
+
],
|
|
41
|
+
"selection": {"contactIds": ["example-contact-1"], "newRevealDimensions": [], "authorizationRef": null},
|
|
42
|
+
"accounts": [
|
|
43
|
+
{"key": "example-account", "organizationIds": ["example-org-1"], "relevantContactIds": ["example-contact-1"], "fallbackContactIds": [], "coverage": "covered", "gap": null, "sourceRefs": ["page-1"]}
|
|
44
|
+
],
|
|
45
|
+
"contacts": [
|
|
46
|
+
{"id": "example-contact-1", "organizationId": "example-org-1", "fit": "relevant", "reason": "Observed facilities title", "localRemit": "unconfirmed", "employmentVerifiedAt": null, "sourceRefs": ["page-1"]}
|
|
47
|
+
],
|
|
48
|
+
"searches": [
|
|
49
|
+
{"operation": "atlas find-contacts", "externalId": "example-search-1", "company": "example-company", "filter": null, "organizationFilter": {"id": {"in": ["example-org-1"]}}, "sort": [], "fields": ["id", "jobTitle", "organization.node.id"], "reveal": "none", "page": {"first": 5}, "status": "COMPLETE", "exitCode": 0, "pageInfo": {"hasNextPage": false, "endCursor": null}, "sourceRef": "page-1"}
|
|
50
|
+
],
|
|
51
|
+
"progress": {"accountsAssessed": 1, "accountsWithRelevantRole": 1, "pendingSearchIds": [], "capsReached": [], "boundary": "requested coverage met; market exhaustiveness not established"}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Authentication tokens, application secrets, cookies, login codes and signed sign-in URLs never
|
|
56
|
+
belong in this journal. Do not store forbidden fields, including phone values when phone access
|
|
57
|
+
is excluded. Keep permission records as references to actual decisions, not invented approvals.
|
|
58
|
+
Protect task state like the underlying customer data; it is not public output or authorization to
|
|
59
|
+
publish captured responses. A source path, timestamp or ID supports traceability, not the truth of
|
|
60
|
+
an unsupported claim.
|
|
61
|
+
|
|
62
|
+
## Update and resume
|
|
63
|
+
|
|
64
|
+
Before another collection call, identify the uncovered account or other reason for it. Reuse
|
|
65
|
+
existing relevant records, keep fallbacks separate and preserve previous exclusions. When a brief
|
|
66
|
+
changes, record the new instruction and its effect rather than silently rewriting the old source.
|
|
67
|
+
A simple filter or re-sort of captured data needs no new Atlas search. Update the view, export and
|
|
68
|
+
coverage together after refinement.
|
|
69
|
+
|
|
70
|
+
Record an accepted search before treating it as finished. A missing response or exit 5 remains
|
|
71
|
+
pending; `FILLING` rows remain provisional even when their cursor says no more pages. Keep them
|
|
72
|
+
out of the final qualified delivery. A `COMPLETE` page permits continuation with its actual cursor,
|
|
73
|
+
not an assumption that the requested account universe or market is exhausted.
|
|
74
|
+
|
|
75
|
+
Preserve company, allowed fields and reveal dimensions on continuation. Follow the actual CLI
|
|
76
|
+
contract in the [Atlas reference](../../sortlist-cli/references/atlas.md). Never resubmit a find
|
|
77
|
+
mutation merely to wait longer, and do not treat an external ID as an idempotency key. Resume an
|
|
78
|
+
accepted request only through a result reader or subscription actually exposed to this caller.
|
|
79
|
+
If none is available, keep that request unresolved and continue independent useful work where
|
|
80
|
+
possible. A deliberately new search for a changed query is a new decision, not a resume; record
|
|
81
|
+
its reason and keep the old pending request visible.
|
|
82
|
+
|
|
83
|
+
Treat expiry and caps explicitly. An expired cursor does not erase already captured records; a
|
|
84
|
+
new search must retain the original scope, deduplicate results and disclose any gap. The current
|
|
85
|
+
1,000-record search cap and ten-contact nested previews do not establish that all matching
|
|
86
|
+
companies or employees were assessed. Do not sum duplicate pages or provisional/final snapshots
|
|
87
|
+
as separate contacts or spend records.
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Sourcing relevant accounts and contacts
|
|
2
|
+
|
|
3
|
+
Use this reference for company discovery, named-account work and contact shortlists. Command
|
|
4
|
+
mechanics, approvals, pricing and resumption belong to `sortlist-cli`.
|
|
5
|
+
|
|
6
|
+
## Establish the output from the brief
|
|
7
|
+
|
|
8
|
+
Identify the requested account set or discovery criteria, the useful function, any product or
|
|
9
|
+
service category, the business territory, and the requested count. Distinguish a total count from a
|
|
10
|
+
count per account. Do not turn missing sales proof, messaging or a campaign channel into a blocker
|
|
11
|
+
for a contact search. If the brief is sufficient, begin without another ICP confirmation.
|
|
12
|
+
|
|
13
|
+
Treat a supplied prospect list or dashboard as evidence of the expected deliverable, including its
|
|
14
|
+
scale, useful columns, prioritization and interactions. Do not quietly replace it with a handful of
|
|
15
|
+
anonymous matches. For a reusable list, an export or a reference deliverable to reproduce, read
|
|
16
|
+
[prospect-list delivery](prospect-list.md) before collecting the final dataset.
|
|
17
|
+
For collection across accounts, pages or follow-up turns, keep the minimal
|
|
18
|
+
[search journal](search-state.md). Reuse the brief and its provenance rather than reconstructing
|
|
19
|
+
the target from whichever account or title was returned most recently.
|
|
20
|
+
|
|
21
|
+
Translate the goal into separate checks:
|
|
22
|
+
|
|
23
|
+
| Dimension | What to establish | What does not establish it |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| Account | The intended company or relevant local entity, its activity and required presence | A similar name, unrelated subsidiary or convenient first result |
|
|
26
|
+
| Function | Responsibility relevant to the proposed purchase or partnership | A senior title alone or a semantic match alone |
|
|
27
|
+
| Category | The relevant product, service, asset or purchasing category, when specified | A broad department that may cover adjacent categories |
|
|
28
|
+
| Territory | Responsibility for the requested market, business unit or site | The person's city, employer headquarters or a broad regional title alone |
|
|
29
|
+
|
|
30
|
+
Do not make a plausible contact unusable merely because budget authority or exact territory is
|
|
31
|
+
unknown. Keep that uncertainty visible. Do not classify a clearly incompatible role as qualified.
|
|
32
|
+
|
|
33
|
+
## Validate accounts before people
|
|
34
|
+
|
|
35
|
+
### Named accounts
|
|
36
|
+
|
|
37
|
+
Start with the supplied names or domains, using normalized exact matching where available. A new
|
|
38
|
+
ICP description filter should not exclude the companies the user explicitly named. Inspect enough
|
|
39
|
+
account evidence to distinguish a company from a namesake, and find relevant aliases or local
|
|
40
|
+
entities when necessary. Read additional pages if the first page leaves requested accounts unresolved.
|
|
41
|
+
|
|
42
|
+
Maintain a small account map for the task:
|
|
43
|
+
|
|
44
|
+
`requested account -> validated organization id(s) and domains -> entity relationship or uncertainty`
|
|
45
|
+
|
|
46
|
+
Group corporate, country and recruitment domains under the same requested account only when there
|
|
47
|
+
is evidence of the relationship. A recruitment domain may hold relevant contacts; do not discard it
|
|
48
|
+
solely because of its domain. Several aliases are not several accounts. Keep unresolved candidates
|
|
49
|
+
separate instead of guessing ownership or substituting a different business. Ask about entity
|
|
50
|
+
ambiguity only when the evidence cannot resolve a choice that materially affects the search.
|
|
51
|
+
|
|
52
|
+
### Discovery
|
|
53
|
+
|
|
54
|
+
Translate what the target companies do into `description` meaning queries, with relevant industry,
|
|
55
|
+
size and location filters as needed. Industry alone is not evidence of the requested activity. Read
|
|
56
|
+
the returned activity and location evidence before retaining accounts. Avoid an unrequested size,
|
|
57
|
+
sector or headquarters restriction.
|
|
58
|
+
|
|
59
|
+
For local demand, establish the relevant office, site or operating presence. A company record's
|
|
60
|
+
location does not by itself prove that a contact manages that site. Resolve place ids through
|
|
61
|
+
Mercator as `sortlist-cli` describes. Choose geography at the organization or contact level according
|
|
62
|
+
to the question, not as an automatic filter on both.
|
|
63
|
+
|
|
64
|
+
Keep three separate evidence states: admitted by the location filter, local presence supported by
|
|
65
|
+
an identified source, and the contact's responsibility for that site. Inspect a suspicious entity,
|
|
66
|
+
domain or country mismatch using available account evidence or an appropriate official source.
|
|
67
|
+
Do not label an obviously foreign namesake a confirmed local establishment merely because Atlas
|
|
68
|
+
returned it. When local presence is plausible but unproved, retain that specific uncertainty rather
|
|
69
|
+
than inventing an address or silently substituting another entity.
|
|
70
|
+
|
|
71
|
+
## Search within validated accounts
|
|
72
|
+
|
|
73
|
+
Read the current command help and relevant schema before using unfamiliar filters or field paths.
|
|
74
|
+
Do not guess a contact country field from an organization's fields. Use explicit preview fields
|
|
75
|
+
such as record id, job title, city and organization id/domain, only where the schema supports them.
|
|
76
|
+
Request reachability only for a channel the user needs; do not require LinkedIn for a role shortlist.
|
|
77
|
+
|
|
78
|
+
Review already supplied or returned contact records before issuing another search. Reuse an adequate
|
|
79
|
+
observed role and record its source; do not search every account again to recreate the same list.
|
|
80
|
+
Nested organization previews currently expose at most ten contacts. An unsuitable first ten do not
|
|
81
|
+
show that no suitable role exists, and field selection does not paginate that nested preview.
|
|
82
|
+
|
|
83
|
+
Use organization ids in `--organization-filter` to constrain contacts to the validated accounts.
|
|
84
|
+
Translate the required function into precise role synonyms and useful local-language variants.
|
|
85
|
+
When a category is required, keep it distinct from the function in the query and in the review.
|
|
86
|
+
Use separate semantic entries for concepts that must both hold, as the current schema supports.
|
|
87
|
+
`INCLUDED_STRICT` remains semantic matching, not exact title equality. A distance sort should use
|
|
88
|
+
`ASC` and the intended responsibility, but the returned title still needs inspection.
|
|
89
|
+
|
|
90
|
+
When the user asks for several people per account, or a shortlist spanning several companies, search
|
|
91
|
+
per account or validated account group so one large account cannot monopolize the preview. Track
|
|
92
|
+
each requested account, including those with no useful result. For a small account set, inspect
|
|
93
|
+
every account before deepening one that is already covered. Use the requested quota; when no quota
|
|
94
|
+
was given, choose a proportionate spread rather than implying a guaranteed yield.
|
|
95
|
+
|
|
96
|
+
Deepen the uncovered or insufficiently covered accounts before adding more people to accounts that
|
|
97
|
+
already meet the target. Start with a small account-scoped page, for example five or ten, and
|
|
98
|
+
`JOB_TITLE_DISTANCE` sorted `ASC` toward the useful responsibility when appropriate. If a narrow
|
|
99
|
+
semantic title filter produces poor coverage, inspecting a small sorted page without it can reveal
|
|
100
|
+
useful existing roles; acceptance still uses the requested function, category and territory.
|
|
101
|
+
Continue relevant pages only while likely to close a real gap. This is a retrieval strategy, not
|
|
102
|
+
a promise of cache-only execution or a measured speedup over different queries.
|
|
103
|
+
|
|
104
|
+
Within each account, deduplicate contact record ids across pages and aliases. Similar titles are
|
|
105
|
+
not proof of duplicate people; locked names do not justify merging different ids. If other evidence
|
|
106
|
+
suggests duplicate records but cannot resolve them, label the uncertainty instead of counting them
|
|
107
|
+
as distinct verified people.
|
|
108
|
+
|
|
109
|
+
## Review function, category and territory
|
|
110
|
+
|
|
111
|
+
Review the actual returned roles rather than passing every match through to the user:
|
|
112
|
+
|
|
113
|
+
- **Relevant candidate:** the available evidence supports a useful function and does not conflict
|
|
114
|
+
with the requested scope. State any unproven category or territorial detail.
|
|
115
|
+
- **Fallback to verify:** a broader or adjacent role could route the opportunity, but does not meet
|
|
116
|
+
a key criterion yet. Keep these separate from the requested qualified coverage.
|
|
117
|
+
- **Outside scope:** a clearly different function, category or territory. Omit from the shortlist;
|
|
118
|
+
a short explanation of a material search problem is more useful than listing irrelevant rows.
|
|
119
|
+
|
|
120
|
+
A regional or global title may cover the target market, even if the person lives abroad. Keep it
|
|
121
|
+
as a candidate or fallback according to the available evidence; do not treat the residence as a
|
|
122
|
+
rejection or the regional title as confirmation of the exact market. Likewise, a central facilities
|
|
123
|
+
role may cover a local site, and a broad buying role may cover the desired category. Those are
|
|
124
|
+
questions to verify, not facts to invent.
|
|
125
|
+
|
|
126
|
+
For physical-site purchasing, inspect common ambiguous meanings in their account context:
|
|
127
|
+
|
|
128
|
+
| Returned evidence | Qualification consequence |
|
|
129
|
+
| --- | --- |
|
|
130
|
+
| Website management or web-site administration | Does not establish responsibility for physical premises. |
|
|
131
|
+
| RAMS or functional safety of a railway/product system | Does not establish building security or facilities ownership. |
|
|
132
|
+
| Technical Director in an animation or creative studio | May concern production; keep as a fallback unless facilities responsibility is supported. |
|
|
133
|
+
| An explicitly former or retired facilities role | Does not establish a current responsible contact; do not confuse a retirement-home employer with a retired person. |
|
|
134
|
+
| Physical Site Manager with an inconsistent IT `jobFunction` | Read the title and account evidence; a noisy category alone does not disqualify an otherwise relevant physical role. |
|
|
135
|
+
| Central facilities owner living elsewhere | Residence does not disqualify them; retain whether the target-site remit is supported or still to confirm. |
|
|
136
|
+
|
|
137
|
+
Keep the exact title, the functional reason and any separate account/site uncertainty. Neither a
|
|
138
|
+
retrieval date nor an available name verifies current employment. Use an employment-verification
|
|
139
|
+
date only when the source provides one, with its scope. Do not infer an active project, authority
|
|
140
|
+
to buy or local responsibility from a name reveal.
|
|
141
|
+
|
|
142
|
+
If a page is dominated by irrelevant roles, refine the responsibility or category query and review
|
|
143
|
+
the results again. If an account is missing, inspect its aliases, remaining pages or role variants
|
|
144
|
+
before widening to unrelated accounts. Keep broad fallbacks visibly separate. Do not silently relax
|
|
145
|
+
the requested territory, function or category to fill a quota.
|
|
146
|
+
|
|
147
|
+
Use a proportionate search effort. Continue relevant pages or refinements while they are likely to
|
|
148
|
+
close the requested coverage within the authorized scope. If progress stalls, report what was
|
|
149
|
+
checked and the remaining gap rather than repeatedly asking to continue or searching indefinitely.
|
|
150
|
+
An incomplete page or a wait timeout is not an empty result. Preserve the accepted search id and
|
|
151
|
+
resume reading as `sortlist-cli` instructs; do not start another find just to wait longer.
|
|
152
|
+
|
|
153
|
+
For a discovery list, a completed first page is not completion of the market search. Track retained
|
|
154
|
+
accounts, contact coverage and remaining pages against the requested scale. Continue within the
|
|
155
|
+
authorized scope, or deliver a clearly identified partial list with the actual boundary that stopped
|
|
156
|
+
collection. The same underlying database does not guarantee the CLI exposes the same fields,
|
|
157
|
+
entitlements, historical snapshot or query coverage as a supplied export; verify those differences
|
|
158
|
+
from observable results rather than attributing every shortfall to missing data.
|
|
159
|
+
An Atlas search currently stops at 1,000 records; ten nested contacts per organization are another
|
|
160
|
+
independent limit. A `COMPLETE` page, no remaining cursor or a reached cap does not establish an
|
|
161
|
+
exhaustive market or employee census. Never request `--total-count` from Atlas to fill this gap.
|
|
162
|
+
|
|
163
|
+
## Deliver the shortlist
|
|
164
|
+
|
|
165
|
+
Lead with the useful result and honest coverage: for example, the number of requested accounts with
|
|
166
|
+
relevant candidates, those with only fallbacks, and those still uncovered. Search totals describe
|
|
167
|
+
engine matches, not a count of qualified decision makers. Report partial or failed searches as
|
|
168
|
+
unresolved, not zero matches.
|
|
169
|
+
|
|
170
|
+
For contacts, a compact chat preview can use:
|
|
171
|
+
|
|
172
|
+
| Account | Contact | Observed role | Why useful | Scope and checks remaining |
|
|
173
|
+
| --- | --- | --- | --- | --- |
|
|
174
|
+
| Validated account and domain | Temporary label, or name already available within authorization | Actual returned title | Evidence supporting the function | Known category/territory, then explicit unknowns |
|
|
175
|
+
|
|
176
|
+
Use stable temporary labels while identity is locked. Do not reveal names just to decorate a
|
|
177
|
+
preview. Include account-level coverage when the request is per account: requested, relevant,
|
|
178
|
+
fallback, missing. Count aliases once. A discovery result should likewise show why each retained
|
|
179
|
+
company matches, not only its domain.
|
|
180
|
+
|
|
181
|
+
Keep this preview short when a full downloadable list accompanies it. Provide the complete retained
|
|
182
|
+
dataset in the requested usable format, following [prospect-list delivery](prospect-list.md), instead
|
|
183
|
+
of pasting hundreds of rows into chat. Do not promise files or interactive controls the host cannot
|
|
184
|
+
actually deliver.
|
|
185
|
+
|
|
186
|
+
Keep clear facts and inferences in ordinary language: "The title supports a purchasing role;
|
|
187
|
+
ownership of this category is unconfirmed." Do not call a candidate a verified budget holder or a
|
|
188
|
+
current decision maker without supporting evidence. Return fewer useful candidates and explicit
|
|
189
|
+
gaps rather than filling the table with incompatible roles.
|
|
190
|
+
|
|
191
|
+
If identity or contact details are part of the requested final deliverable, preview the candidates
|
|
192
|
+
first and obtain any missing bounded reveal authorization under `sortlist-cli`. Use only the chosen
|
|
193
|
+
ids and needed dimensions, respecting exclusions. A contact shortlist does not authorize outreach,
|
|
194
|
+
watchers or unrelated enrichment.
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Standalone, dependency-free delivery helper. It never calls Atlas or any service.
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const text = (value) => value == null ? '' : String(value);
|
|
8
|
+
const strings = (values) => Array.isArray(values) ? values.map(text).filter(Boolean) : [];
|
|
9
|
+
const list = (value) => Array.isArray(value) ? value : [];
|
|
10
|
+
const pick = (value, keys) => Object.fromEntries(keys.map((key) => [key, text(value?.[key])]));
|
|
11
|
+
const escape = (value) => text(value).replace(/[&<>"']/g, (character) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[character]));
|
|
12
|
+
|
|
13
|
+
export function normalizeProspects(input) {
|
|
14
|
+
if (!input || !Array.isArray(input.companies)) throw new Error('Input must contain a companies array.');
|
|
15
|
+
const companies = input.companies.map((company, index) => {
|
|
16
|
+
const row = pick(company, ['id', 'name', 'domain', 'city', 'size', 'sector', 'priority', 'reason']);
|
|
17
|
+
row.id ||= `company-${index + 1}`;
|
|
18
|
+
if (!row.name && !row.domain) throw new Error(`Company ${index + 1} needs a returned name or domain.`);
|
|
19
|
+
row.evidence = list(company.evidence).map((item) => pick(item, ['fact', 'source', 'asOf']));
|
|
20
|
+
row.contacts = list(company.contacts).map((contact, contactIndex) => {
|
|
21
|
+
const result = pick(contact, ['id', 'name', 'title', 'fit', 'reason', 'scope', 'email', 'emailStatus', 'linkedin', 'asOf']);
|
|
22
|
+
result.id ||= `${row.id}-contact-${contactIndex + 1}`;
|
|
23
|
+
if (!result.name && !result.title) throw new Error(`Contact ${result.id} needs an observed name or role. Omit empty contact placeholders.`);
|
|
24
|
+
if (!['relevant', 'fallback', 'unverified'].includes(result.fit)) result.fit = 'unverified';
|
|
25
|
+
return result;
|
|
26
|
+
});
|
|
27
|
+
if (new Set(row.contacts.map((contact) => contact.id)).size !== row.contacts.length) throw new Error(`Duplicate contact ID in ${row.id}. Deduplicate before delivery.`);
|
|
28
|
+
return row;
|
|
29
|
+
});
|
|
30
|
+
if (new Set(companies.map((company) => company.id)).size !== companies.length) throw new Error('Duplicate company IDs. Deduplicate before delivery.');
|
|
31
|
+
const contactIds = companies.flatMap((company) => company.contacts.map((contact) => contact.id));
|
|
32
|
+
if (new Set(contactIds).size !== contactIds.length) throw new Error('Duplicate contact IDs across companies. Resolve aliases before delivery.');
|
|
33
|
+
return {
|
|
34
|
+
...pick(input, ['title', 'description', 'asOf']),
|
|
35
|
+
scope: {
|
|
36
|
+
...pick(input.scope, ['summary', 'coverage', 'completion']),
|
|
37
|
+
filters: strings(input.scope?.filters),
|
|
38
|
+
exclusions: strings(input.scope?.exclusions),
|
|
39
|
+
limits: strings(input.scope?.limits),
|
|
40
|
+
},
|
|
41
|
+
priorities: Object.fromEntries(Object.entries(input.priorities ?? {}).map(([key, value]) => [key, text(value)])),
|
|
42
|
+
companies,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function flattenRows(data) {
|
|
47
|
+
return data.companies.flatMap((company) => (company.contacts.length ? company.contacts : [null]).map((contact) => ({ company, contact })));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// The same functions run in Node and in the delivered HTML. Filters and CSV share one row set.
|
|
51
|
+
export function selectRows(rows, filters = {}) {
|
|
52
|
+
const normalized = (value) => String(value ?? '').normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase();
|
|
53
|
+
const query = normalized(filters.query).trim();
|
|
54
|
+
return rows.filter(({ company, contact }) => {
|
|
55
|
+
if (filters.city && company.city !== filters.city) return false;
|
|
56
|
+
if (filters.priority && company.priority !== filters.priority) return false;
|
|
57
|
+
if (filters.sector && company.sector !== filters.sector) return false;
|
|
58
|
+
if (filters.size && company.size !== filters.size) return false;
|
|
59
|
+
if (filters.fit && contact?.fit !== filters.fit) return false;
|
|
60
|
+
if (filters.email && !contact?.email) return false;
|
|
61
|
+
return !query || normalized([company.name, company.domain, company.city, company.sector, company.reason, contact?.name, contact?.title, contact?.reason, contact?.scope].join(' ')).includes(query);
|
|
62
|
+
}).sort((a, b) => {
|
|
63
|
+
if (filters.sort === 'company') return (a.company.name || a.company.domain).localeCompare(b.company.name || b.company.domain, 'fr');
|
|
64
|
+
if (filters.sort === 'priority') return (a.company.priority || '\uffff').localeCompare(b.company.priority || '\uffff', 'fr');
|
|
65
|
+
if (filters.sort === 'size') return (parseInt(b.company.size.replace(/\s/g, ''), 10) || 0) - (parseInt(a.company.size.replace(/\s/g, ''), 10) || 0);
|
|
66
|
+
return 0;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function makeCSV(rows) {
|
|
71
|
+
const cell = (value) => {
|
|
72
|
+
let source = String(value ?? '');
|
|
73
|
+
// Prevent contact or company content from becoming an executable spreadsheet formula.
|
|
74
|
+
if (/^[\s\uFEFF]*[=+@-]/.test(source)) source = `'${source}`;
|
|
75
|
+
return `"${source.replaceAll('"', '""')}"`;
|
|
76
|
+
};
|
|
77
|
+
const columns = ['Entreprise', 'Domaine', 'Ville', 'Effectif', 'Secteur', 'Priorité', 'Pourquoi cette entreprise', 'Contact', 'Fonction', 'Pertinence', 'Pourquoi cet interlocuteur', 'Périmètre à vérifier', 'Email disponible', 'Statut email fourni', 'LinkedIn', 'Date contact fournie', 'Preuves entreprise'];
|
|
78
|
+
return '\uFEFF' + [columns, ...rows.map(({ company: c, contact: p }) => [c.name, c.domain, c.city, c.size, c.sector, c.priority, c.reason, p?.name, p?.title, p?.fit, p?.reason, p?.scope, p?.email, p?.emailStatus, p?.linkedin, p?.asOf, c.evidence.map((e) => [e.fact, e.source, e.asOf].filter(Boolean).join(' | ')).join(' ; ')])].map((row) => row.map(cell).join(';')).join('\r\n') + '\r\n';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function renderProspects(data) {
|
|
82
|
+
// Escape the script context as well as visible HTML. Source data is never executed.
|
|
83
|
+
const payload = JSON.stringify(data).replaceAll('<', '\\u003c').replaceAll('\u2028', '\\u2028').replaceAll('\u2029', '\\u2029');
|
|
84
|
+
const coverage = data.scope.completion || data.scope.coverage ? '<div class="coverage"><strong>' + escape(data.scope.completion) + '</strong>' + (data.scope.coverage ? '<div class="sub">' + escape(data.scope.coverage) + '</div>' : '') + '</div>' : '';
|
|
85
|
+
return `<!doctype html>
|
|
86
|
+
<html lang="fr"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
87
|
+
<title>${escape(data.title || 'Votre vivier de prospection')}</title>
|
|
88
|
+
<style>
|
|
89
|
+
:root{font:15px/1.5 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#182923;background:#f6f7f2;--ink:#182923;--muted:#5c6a63;--line:#dce3da;--accent:#136b4e}
|
|
90
|
+
*{box-sizing:border-box}body{margin:0}button,input,select{font:inherit}button,a,input,select{outline-offset:4px}a{color:var(--accent)}main{max-width:1440px;margin:auto;padding:40px 34px 64px}.eyebrow{color:var(--accent);font-size:12px;font-weight:750;letter-spacing:.13em;text-transform:uppercase}h1{font-size:clamp(28px,3.5vw,46px);line-height:1.1;letter-spacing:-.04em;margin:12px 0 14px}.intro{max-width:900px;color:var(--muted);margin:0}.meta{font-size:12px;color:var(--muted);margin-top:12px}.top{display:flex;align-items:start;justify-content:space-between;gap:24px}.button{border:1px solid var(--line);background:white;border-radius:10px;color:var(--ink);padding:10px 15px;cursor:pointer;white-space:nowrap}.button.primary{background:var(--ink);color:white;border-color:var(--ink)}.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin:28px 0 22px}.stat{background:white;border:1px solid var(--line);border-radius:14px;padding:16px 20px}.stat strong{font-size:30px;letter-spacing:-.04em;display:block}.stat span{font-size:12px;color:var(--muted)}.panel{border:1px solid var(--line);background:white;border-radius:14px;padding:18px 20px;margin-bottom:18px}details summary{cursor:pointer;font-weight:650}.scope{color:var(--muted);font-size:13px;margin-top:12px}.scope p{margin:7px 0}.scope ul{padding-left:20px}.filters{display:grid;grid-template-columns:2fr 1fr 1fr 1.3fr;gap:12px;align-items:end}label{font-size:12px;color:var(--muted);display:block}input[type=search],select{width:100%;padding:10px 12px;margin-top:5px;border:1px solid #cfd9cf;border-radius:8px;background:white;color:var(--ink)}.filter-extra{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-top:14px}.check{display:flex;align-items:center;gap:7px;font-size:13px}.toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:22px 0 12px}.toolbar p{font-size:13px;color:var(--muted);margin:0}.table-wrap{overflow:auto;border:1px solid var(--line);border-radius:14px;background:white}table{border-collapse:collapse;width:100%;min-width:950px}th{text-align:left;font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);background:#eef2eb;padding:14px 18px}td{vertical-align:top;padding:18px;border-top:1px solid #e6ebe3;font-size:13px}td:first-child{width:25%}td:nth-child(2){width:31%}td:nth-child(3){width:30%}.company{font-size:15px;font-weight:700}.sub{color:var(--muted);font-size:12px;margin-top:5px}.contact{font-weight:700;font-size:14px}.title{margin:4px 0 8px}.badge{display:inline-block;border-radius:5px;padding:3px 7px;font-size:10px;font-weight:750;letter-spacing:.02em;background:#eef2eb;color:#41534a;margin-bottom:8px}.badge.relevant,.badge.A{background:#e2f2e8;color:#226b46}.badge.fallback,.badge.B{background:#fff0d7;color:#845d19}.badge.unverified,.badge.C{background:#eef0f4;color:#596573}.links{display:flex;gap:12px;flex-wrap:wrap;font-size:12px;margin-top:10px}.reason{margin:0 0 8px}.empty{text-align:center;padding:40px;color:var(--muted)}.footer{font-size:12px;color:var(--muted);margin-top:16px}.quiet{font-size:12px;color:var(--muted)}@media(max-width:760px){main{padding:24px 16px}.top{display:block}.top .button{margin-top:20px}.stats{grid-template-columns:repeat(2,1fr)}.filters{grid-template-columns:1fr 1fr}.filters label:first-child{grid-column:1/-1}.toolbar,.filter-extra{align-items:start;flex-wrap:wrap}h1{font-size:33px}}
|
|
91
|
+
main{padding-top:28px}h1{font-size:clamp(27px,3vw,38px);margin:8px 0 10px}.intro{font-size:14px}.meta{margin-top:7px}.stats{margin:20px 0 12px;gap:12px}.stat{padding:10px 16px}.stat strong{font-size:26px}.coverage{padding:9px 14px;border-left:3px solid var(--accent);background:#edf4ec;margin:0 0 12px;font-size:13px}.coverage .sub{margin-top:2px}#scope{padding:10px 16px;margin-bottom:12px;font-size:13px}.panel{padding:13px 16px;margin-bottom:12px}.filters{gap:10px}.filter-extra{margin-top:10px}.toolbar{margin:16px 0 10px}td{padding:14px 16px}.title{margin:4px 0 6px}.contact-detail{margin:6px 0}.contact-detail p{max-width:380px}.reason{margin-bottom:6px}
|
|
92
|
+
</style></head><body><main>
|
|
93
|
+
<div class="top"><div><div class="eyebrow">Votre prospection, au même endroit</div><h1>${escape(data.title || 'Votre vivier de prospection')}</h1><p class="intro">${escape(data.description)}</p><div class="meta">${data.asOf ? `Données présentées au ${escape(data.asOf)}. ` : ''}La date d’extraction ne certifie pas l’actualité de chaque fiche.</div></div><button type="button" class="button primary" id="export-top">Exporter la sélection CSV</button></div>
|
|
94
|
+
<div class="stats" aria-live="polite"><div class="stat"><strong id="company-count">0</strong><span>entreprises affichées</span></div><div class="stat"><strong id="contact-count">0</strong><span>interlocuteurs affichés</span></div><div class="stat"><strong id="relevant-count">0</strong><span>rôles pertinents</span></div><div class="stat"><strong id="email-count">0</strong><span>emails renseignés</span></div></div>
|
|
95
|
+
${coverage}
|
|
96
|
+
<details class="panel" id="scope"><summary>Périmètre, priorités et limites de cette liste</summary><div class="scope" id="scope-content"></div></details>
|
|
97
|
+
<div class="panel"><div class="filters"><label>Rechercher une entreprise, une personne, une fonction<input id="query" type="search" placeholder="Ex. maintenance, Mons…"></label><label>Ville<select id="city"><option value="">Toutes les villes</option></select></label><label>Priorité<select id="priority"><option value="">Toutes les priorités</option></select></label><label>Interlocuteur<select id="fit"><option value="">Tous les interlocuteurs</option><option value="relevant">Rôle pertinent</option><option value="fallback">Point d’entrée en repli</option><option value="unverified">À vérifier</option></select></label><label>Secteur<select id="sector"><option value="">Tous les secteurs</option></select></label><label>Effectif fourni<select id="size"><option value="">Toutes les tailles</option></select></label><label>Trier la liste<select id="sort"><option value="">Ordre retenu</option><option value="priority">Priorité</option><option value="company">Entreprise A à Z</option><option value="size">Effectif décroissant</option></select></label></div><div class="filter-extra"><label class="check"><input id="email" type="checkbox">Seulement les contacts avec un email renseigné</label><button type="button" class="button" id="reset">Réinitialiser les filtres</button></div></div>
|
|
98
|
+
<div class="toolbar"><p id="selection" aria-live="polite"></p><button type="button" class="button" id="export">Exporter la sélection CSV</button></div>
|
|
99
|
+
<div class="table-wrap"><table><thead><tr><th>Entreprise</th><th>Qui contacter</th><th>Pourquoi cette piste</th><th>Priorité</th></tr></thead><tbody id="results"></tbody></table><div id="empty" class="empty" hidden>Aucun résultat avec ces filtres. Essayez une autre sélection.</div></div>
|
|
100
|
+
<p class="footer">Le CSV contient exactement les lignes affichées, une ligne par interlocuteur. Un email renseigné n’est pas, à lui seul, une preuve de validité. Les responsabilités, besoins et équipements non documentés restent à confirmer.</p>
|
|
101
|
+
</main><script type="application/json" id="data">${payload}</script><script>
|
|
102
|
+
const data=JSON.parse(document.getElementById('data').textContent);
|
|
103
|
+
${selectRows.toString()}
|
|
104
|
+
${makeCSV.toString()}
|
|
105
|
+
const rows=data.companies.flatMap(company=>(company.contacts.length?company.contacts:[null]).map(contact=>({company,contact})));
|
|
106
|
+
const byId=id=>document.getElementById(id);
|
|
107
|
+
const esc=value=>String(value??'').replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
|
108
|
+
const fitNames={relevant:'Rôle pertinent',fallback:'Point d’entrée en repli',unverified:'À vérifier'};
|
|
109
|
+
const url=(value,kind)=>{try{const u=new URL(kind==='site'&&!/^[a-z]+:/i.test(value)?'https://'+value:value);return ['http:','https:'].includes(u.protocol)?u.href:null}catch{return null}};
|
|
110
|
+
const link=(href,label)=>href?'<a href="'+esc(href)+'" target="_blank" rel="noopener noreferrer">'+esc(label)+'</a>':'';
|
|
111
|
+
for(const key of ['city','priority','sector','size'])for(const value of [...new Set(data.companies.map(c=>c[key]).filter(Boolean))].sort((a,b)=>a.localeCompare(b,'fr'))){const option=document.createElement('option');option.value=option.textContent=value;byId(key).append(option)}
|
|
112
|
+
const scope=data.scope;
|
|
113
|
+
byId('scope-content').innerHTML=[scope.summary,scope.coverage,scope.completion].filter(Boolean).map(t=>'<p>'+esc(t)+'</p>').join('')+[['Ciblage',scope.filters],['Exclusions',scope.exclusions],['Limites',scope.limits],['Lecture des priorités',Object.entries(data.priorities).map(([k,v])=>k+' : '+v)]].filter(([,v])=>v.length).map(([title,values])=>'<strong>'+esc(title)+'</strong><ul>'+values.map(v=>'<li>'+esc(v)+'</li>').join('')+'</ul>').join('');
|
|
114
|
+
let visible=[];
|
|
115
|
+
function refresh(){
|
|
116
|
+
const filters={query:byId('query').value,city:byId('city').value,priority:byId('priority').value,fit:byId('fit').value,sector:byId('sector').value,size:byId('size').value,sort:byId('sort').value,email:byId('email').checked};
|
|
117
|
+
visible=selectRows(rows,filters);
|
|
118
|
+
const contacts=visible.filter(r=>r.contact);
|
|
119
|
+
byId('company-count').textContent=new Set(visible.map(r=>r.company.id)).size;
|
|
120
|
+
byId('contact-count').textContent=contacts.length;
|
|
121
|
+
byId('relevant-count').textContent=contacts.filter(r=>r.contact.fit==='relevant').length;
|
|
122
|
+
byId('email-count').textContent=contacts.filter(r=>r.contact.email).length;
|
|
123
|
+
byId('selection').textContent=visible.length+' lignes affichées sur '+rows.length+'. Les filtres s’appliquent aux interlocuteurs et au CSV.';
|
|
124
|
+
byId('empty').hidden=visible.length!==0;
|
|
125
|
+
byId('results').innerHTML=visible.map(({company:c,contact:p})=>{
|
|
126
|
+
const site=url(c.domain,'site');
|
|
127
|
+
const identity=p?.name||'Identité non disponible';
|
|
128
|
+
const contact=p?'<div class="badge '+esc(p.fit)+'">'+esc(fitNames[p.fit])+'</div><div class="contact">'+esc(identity)+'</div><div class="title">'+esc(p.title||'Fonction non renseignée')+'</div>'+(p.scope?'<details class="sub contact-detail"><summary>Périmètre du rôle</summary><p>'+esc(p.scope)+'</p></details>':'')+'<div class="links">'+(p.email?'<a href="mailto:'+esc(encodeURIComponent(p.email))+'">'+esc(p.email)+'</a>':'<span class="quiet">Email non disponible</span>')+link(url(p.linkedin),'LinkedIn')+'</div>'+(p.email&&p.emailStatus?'<div class="sub">Statut email fourni : '+esc(p.emailStatus)+'</div>':'')+(p.asOf?'<div class="sub">Date contact fournie : '+esc(p.asOf)+'</div>':''):'<div class="badge unverified">Contact à trouver</div><div class="sub">Aucun interlocuteur retenu pour cette entreprise.</div>';
|
|
129
|
+
return '<tr><td><div class="company">'+(site?link(site,c.name||c.domain):esc(c.name||c.domain))+'</div><div class="sub">'+esc([c.city,c.size].filter(Boolean).join(' · '))+'</div><div class="sub">'+esc(c.sector)+'</div></td><td>'+contact+'</td><td><p class="reason">'+esc(c.reason)+'</p>'+(p?.reason?'<div>'+esc(p.reason)+'</div>':'')+(c.evidence.length?'<details class="sub"><summary>Voir les éléments fournis</summary>'+c.evidence.map(e=>'<p>'+esc(e.fact)+'<br>'+esc([e.source,e.asOf].filter(Boolean).join(' · '))+'</p>').join('')+'</details>':'')+'</td><td>'+(c.priority?'<span class="badge '+(['A','B','C'].includes(c.priority)?c.priority:'')+'">'+esc(c.priority)+'</span>':'<span class="quiet">Non classée</span>')+'</td></tr>'
|
|
130
|
+
}).join('');
|
|
131
|
+
}
|
|
132
|
+
for(const id of ['query','city','priority','fit','email','sector','size','sort'])byId(id).addEventListener('input',refresh);
|
|
133
|
+
byId('reset').addEventListener('click',()=>{for(const id of ['query','city','priority','fit','sector','size','sort'])byId(id).value='';byId('email').checked=false;refresh()});
|
|
134
|
+
function download(){const blob=new Blob([makeCSV(visible)],{type:'text/csv;charset=utf-8'});const href=URL.createObjectURL(blob);const a=document.createElement('a');a.href=href;a.download='prospects-selection.csv';a.click();setTimeout(()=>URL.revokeObjectURL(href),1000)}
|
|
135
|
+
byId('export').addEventListener('click',download);byId('export-top').addEventListener('click',download);refresh();
|
|
136
|
+
</script></body></html>`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function main(args) {
|
|
140
|
+
if (args.includes('--help')) {
|
|
141
|
+
process.stdout.write(`Usage: node render-prospect-list.mjs --input list.json --out new-directory\n\nOffline helper, no service calls. Writes index.html, prospects.csv, state.json.\nOutput directory must be empty; existing deliveries are never overwritten.\nOnly the following fields survive normalization; phone fields and credentials are ignored.\n\nInput:\n{title, description, asOf,\n scope:{summary, filters:[], exclusions:[], coverage, completion, limits:[]},\n priorities:{A:"rule", B:"rule", C:"rule"},\n companies:[{id, name, domain, city, size, sector, priority, reason,\n evidence:[{fact, source, asOf}],\n contacts:[{id, name, title, fit:"relevant|fallback|unverified", reason, scope,\n email, emailStatus, linkedin, asOf}]}]}\n\nUse only observed or user-supplied data. Leave unknown identities/channels empty.\nAssess role relevance and priority before rendering. This helper does not qualify leads.\nstate.json preserves normalized delivery data, not API tokens or search cursors.\nRetain restricted search continuation context separately in the host.\nThe HTML runs offline and exports exactly its filtered contact rows.\nDeliver the files through actual host attachments or links. No upload or hosting is performed.\n`);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (args.length !== 4 || !args.includes('--input') || !args.includes('--out')) throw new Error('Expected --input <file> --out <empty-directory>. Use --help for the schema.');
|
|
145
|
+
const inputPath = path.resolve(args[args.indexOf('--input') + 1]);
|
|
146
|
+
const output = path.resolve(args[args.indexOf('--out') + 1]);
|
|
147
|
+
const data = normalizeProspects(JSON.parse(fs.readFileSync(inputPath, 'utf8')));
|
|
148
|
+
if (fs.existsSync(output) && fs.readdirSync(output).length) throw new Error('Output directory is not empty. Choose a new directory for this revision.');
|
|
149
|
+
fs.mkdirSync(output, { recursive: true, mode: 0o700 });
|
|
150
|
+
const artifacts = { 'index.html': renderProspects(data), 'prospects.csv': makeCSV(flattenRows(data)), 'state.json': JSON.stringify(data, null, 2) + '\n' };
|
|
151
|
+
for (const [filename, content] of Object.entries(artifacts)) fs.writeFileSync(path.join(output, filename), content, { flag: 'wx', mode: 0o600 });
|
|
152
|
+
process.stdout.write(JSON.stringify({ directory: output, files: Object.keys(artifacts), companies: data.companies.length, contacts: data.companies.reduce((sum, company) => sum + company.contacts.length, 0) }) + '\n');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
156
|
+
try { main(process.argv.slice(2)); } catch (error) { process.stderr.write(`${error.message}\n`); process.exitCode = 1; }
|
|
157
|
+
}
|