@indigoai-us/hq-cli 5.47.14 → 5.47.16
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/commands/pack-install.d.ts +14 -0
- package/dist/commands/pack-install.js +76 -2
- package/dist/commands/packs.d.ts +32 -0
- package/dist/commands/packs.js +20 -3
- package/dist/commands/people.d.ts +22 -0
- package/dist/commands/people.js +187 -0
- package/dist/index.js +6 -2
- package/dist/types.d.ts +10 -0
- package/dist/utils/people.d.ts +99 -0
- package/dist/utils/people.js +168 -0
- package/package.json +1 -1
- package/src/commands/pack-install.test.ts +213 -0
- package/src/commands/pack-install.ts +82 -0
- package/src/commands/packs.test.ts +88 -0
- package/src/commands/packs.ts +24 -1
- package/src/commands/people.test.ts +426 -0
- package/src/commands/people.ts +240 -0
- package/src/index.ts +4 -0
- package/src/schemas/hq-package.schema.json +18 -0
- package/src/types.ts +7 -0
- package/src/utils/people.ts +222 -0
|
@@ -132,6 +132,24 @@
|
|
|
132
132
|
"minLength": 1
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
|
+
},
|
|
136
|
+
"initialization": {
|
|
137
|
+
"type": "object",
|
|
138
|
+
"description": "Optional post-install onboarding. `entrypoint` is the pack's primary get-started action (a skill or command that must resolve to one of this package's exposes.skills / exposes.commands entries); HQ surfaces a safe auto-generated 'get started' line from it after install. `prompt` is optional free-text the user can copy/paste into their agent to begin setup — treated as UNTRUSTED instruction text, surfaced only after marketplace injection-scan/moderation (suppressed for non-marketplace installs).",
|
|
139
|
+
"additionalProperties": false,
|
|
140
|
+
"properties": {
|
|
141
|
+
"entrypoint": {
|
|
142
|
+
"type": "string",
|
|
143
|
+
"minLength": 1,
|
|
144
|
+
"description": "Primary get-started action — a skill or command name (with or without a leading slash) that must resolve to a declared exposes.skills / exposes.commands entry."
|
|
145
|
+
},
|
|
146
|
+
"prompt": {
|
|
147
|
+
"type": "string",
|
|
148
|
+
"maxLength": 2000,
|
|
149
|
+
"description": "Optional copy/paste setup prompt. Untrusted; surfaced only after moderation for marketplace packs, suppressed for local/git installs."
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"required": ["entrypoint"]
|
|
135
153
|
}
|
|
136
154
|
}
|
|
137
155
|
}
|
package/src/types.ts
CHANGED
|
@@ -117,4 +117,11 @@ export interface PackManifest {
|
|
|
117
117
|
* yet enforced.
|
|
118
118
|
*/
|
|
119
119
|
capabilities?: string[];
|
|
120
|
+
/**
|
|
121
|
+
* Post-install initialization (US-004/US-005). Optional — absent on legacy
|
|
122
|
+
* packs. `entrypoint` names a declared `contributes.skills`/`commands` entry
|
|
123
|
+
* (slash-normalized); `prompt` is optional free-text prose (PHASE 1 does NOT
|
|
124
|
+
* render the prose — only an auto-generated get-started line from entrypoint).
|
|
125
|
+
*/
|
|
126
|
+
initialization?: { entrypoint: string; prompt?: string };
|
|
120
127
|
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Company people (membership) directory reader + search.
|
|
3
|
+
*
|
|
4
|
+
* The local source of truth for "who belongs to a company" is the per-company
|
|
5
|
+
* people store on disk:
|
|
6
|
+
*
|
|
7
|
+
* companies/<company-slug>/people/<person-slug>/meta.yaml
|
|
8
|
+
*
|
|
9
|
+
* Each `meta.yaml` carries at least `name` and `type` ("internal" | "external")
|
|
10
|
+
* plus optional `email`, `role`, `organization`, `tags`, etc. (see
|
|
11
|
+
* `companies/_template/people/_example/meta.yaml` for the canonical schema).
|
|
12
|
+
*
|
|
13
|
+
* Everything here is scoped to ONE company directory. Callers resolve a single
|
|
14
|
+
* company slug up front; nothing in this module ever enumerates or reads across
|
|
15
|
+
* company boundaries — HQ tenancy rules forbid cross-company member lookups.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import * as fs from "fs";
|
|
19
|
+
import * as path from "path";
|
|
20
|
+
import * as yaml from "js-yaml";
|
|
21
|
+
|
|
22
|
+
/** A single person/member record parsed from a `people/<slug>/meta.yaml`. */
|
|
23
|
+
export interface PersonRecord {
|
|
24
|
+
/** Folder slug under `companies/<company>/people/<slug>/`. */
|
|
25
|
+
slug: string;
|
|
26
|
+
/** Display name (required field in `meta.yaml`). */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Contact email, when recorded. */
|
|
29
|
+
email?: string;
|
|
30
|
+
/** "internal" (team member) | "external" (client, vendor, …). */
|
|
31
|
+
type?: string;
|
|
32
|
+
/** Role/title inside (or relative to) the company. */
|
|
33
|
+
role?: string;
|
|
34
|
+
/** External-only: the person's own organization. */
|
|
35
|
+
organization?: string;
|
|
36
|
+
/** Freeform tags for filtering. */
|
|
37
|
+
tags?: string[];
|
|
38
|
+
/** Absolute path to the `meta.yaml` this record was parsed from. */
|
|
39
|
+
source: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Company slugs map directly onto a filesystem path segment, so we validate
|
|
44
|
+
* them before joining to keep a malicious or fat-fingered `--company` value
|
|
45
|
+
* from escaping the `companies/` tree. Mirrors the slug rules used by
|
|
46
|
+
* cloud-provision.
|
|
47
|
+
*/
|
|
48
|
+
const COMPANY_SLUG_REGEX = /^[A-Za-z0-9._-]+$/;
|
|
49
|
+
const FORBIDDEN_COMPANY_SLUGS = new Set(["personal", ".", ".."]);
|
|
50
|
+
|
|
51
|
+
export function assertSafeCompanySlug(slug: string): void {
|
|
52
|
+
if (!slug || !COMPANY_SLUG_REGEX.test(slug)) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
`Invalid company slug "${slug}" — must match ${COMPANY_SLUG_REGEX.source}`,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
if (FORBIDDEN_COMPANY_SLUGS.has(slug)) {
|
|
58
|
+
throw new Error(`Company slug "${slug}" is reserved and cannot be used here`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Absolute path to a company's `people/` directory. */
|
|
63
|
+
export function companyPeopleDir(hqRoot: string, companySlug: string): string {
|
|
64
|
+
assertSafeCompanySlug(companySlug);
|
|
65
|
+
return path.join(hqRoot, "companies", companySlug, "people");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Parse a single `meta.yaml` body into a `PersonRecord`. Returns `null` when the
|
|
70
|
+
* file is empty, unparseable, or has no usable `name` — a person record without
|
|
71
|
+
* a name can't be listed, searched, or resolved, so it's skipped rather than
|
|
72
|
+
* surfaced as a half-row. Exported for unit testing.
|
|
73
|
+
*/
|
|
74
|
+
export function parsePersonMeta(
|
|
75
|
+
raw: string,
|
|
76
|
+
slug: string,
|
|
77
|
+
source: string,
|
|
78
|
+
): PersonRecord | null {
|
|
79
|
+
let doc: unknown;
|
|
80
|
+
try {
|
|
81
|
+
doc = yaml.load(raw);
|
|
82
|
+
} catch (err) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`Failed to parse ${source}: ${err instanceof Error ? err.message : String(err)}`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
if (!doc || typeof doc !== "object") return null;
|
|
88
|
+
const d = doc as Record<string, unknown>;
|
|
89
|
+
|
|
90
|
+
const name = typeof d.name === "string" ? d.name.trim() : "";
|
|
91
|
+
if (!name) return null;
|
|
92
|
+
|
|
93
|
+
const str = (v: unknown): string | undefined =>
|
|
94
|
+
typeof v === "string" && v.trim() ? v.trim() : undefined;
|
|
95
|
+
|
|
96
|
+
const tags = Array.isArray(d.tags)
|
|
97
|
+
? d.tags.filter((t): t is string => typeof t === "string")
|
|
98
|
+
: undefined;
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
slug,
|
|
102
|
+
name,
|
|
103
|
+
email: str(d.email),
|
|
104
|
+
type: str(d.type),
|
|
105
|
+
role: str(d.role),
|
|
106
|
+
organization: str(d.organization),
|
|
107
|
+
...(tags && tags.length > 0 ? { tags } : {}),
|
|
108
|
+
source,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* List every person recorded for ONE company. Reads
|
|
114
|
+
* `companies/<companySlug>/people/<personSlug>/meta.yaml` for each person
|
|
115
|
+
* folder.
|
|
116
|
+
*
|
|
117
|
+
* - Folders whose name starts with `_` are skipped (e.g. the `_example`
|
|
118
|
+
* template that ships in `companies/_template/people/`).
|
|
119
|
+
* - Folders without a `meta.yaml`, or whose `meta.yaml` has no `name`, are
|
|
120
|
+
* skipped silently — they aren't members yet.
|
|
121
|
+
* - Returns `[]` when the company has no `people/` directory at all.
|
|
122
|
+
*
|
|
123
|
+
* Results are sorted by name (case-insensitive) for stable output.
|
|
124
|
+
*/
|
|
125
|
+
export function listCompanyPeople(
|
|
126
|
+
hqRoot: string,
|
|
127
|
+
companySlug: string,
|
|
128
|
+
): PersonRecord[] {
|
|
129
|
+
const dir = companyPeopleDir(hqRoot, companySlug);
|
|
130
|
+
if (!fs.existsSync(dir)) return [];
|
|
131
|
+
|
|
132
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
133
|
+
const people: PersonRecord[] = [];
|
|
134
|
+
|
|
135
|
+
for (const entry of entries) {
|
|
136
|
+
if (!entry.isDirectory()) continue;
|
|
137
|
+
if (entry.name.startsWith("_")) continue; // _example and other scaffolding
|
|
138
|
+
|
|
139
|
+
const metaPath = path.join(dir, entry.name, "meta.yaml");
|
|
140
|
+
if (!fs.existsSync(metaPath)) continue;
|
|
141
|
+
|
|
142
|
+
const raw = fs.readFileSync(metaPath, "utf-8");
|
|
143
|
+
const record = parsePersonMeta(raw, entry.name, metaPath);
|
|
144
|
+
if (record) people.push(record);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
people.sort((a, b) =>
|
|
148
|
+
a.name.localeCompare(b.name, undefined, { sensitivity: "base" }),
|
|
149
|
+
);
|
|
150
|
+
return people;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Case-insensitive keyword search over a person's NAME and EMAIL (plus the
|
|
155
|
+
* folder slug, which is a normalized alias of the name). Pure — operates on an
|
|
156
|
+
* already-loaded list so it's trivially testable and reusable.
|
|
157
|
+
*
|
|
158
|
+
* An empty/whitespace keyword matches nothing (callers should treat that as a
|
|
159
|
+
* usage error rather than "return everyone").
|
|
160
|
+
*/
|
|
161
|
+
export function searchPeople(
|
|
162
|
+
people: PersonRecord[],
|
|
163
|
+
keyword: string,
|
|
164
|
+
): PersonRecord[] {
|
|
165
|
+
const needle = keyword.trim().toLowerCase();
|
|
166
|
+
if (!needle) return [];
|
|
167
|
+
return people.filter((p) => {
|
|
168
|
+
const haystacks = [p.name, p.email, p.slug].filter(
|
|
169
|
+
(v): v is string => typeof v === "string",
|
|
170
|
+
);
|
|
171
|
+
return haystacks.some((h) => h.toLowerCase().includes(needle));
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Outcome of resolving a name to an email address. */
|
|
176
|
+
export type ResolveResult =
|
|
177
|
+
| { status: "found"; email: string; person: PersonRecord }
|
|
178
|
+
| { status: "no_email"; person: PersonRecord }
|
|
179
|
+
| { status: "ambiguous"; matches: PersonRecord[] }
|
|
180
|
+
| { status: "not_found" };
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Resolve a person NAME to their email, built on top of {@link searchPeople}.
|
|
184
|
+
*
|
|
185
|
+
* Match precedence (narrowest first) so a precise query isn't drowned out by
|
|
186
|
+
* looser substring hits:
|
|
187
|
+
* 1. exact name match (case-insensitive, trimmed)
|
|
188
|
+
* 2. exact folder-slug match
|
|
189
|
+
* 3. substring search over name/email/slug
|
|
190
|
+
*
|
|
191
|
+
* The first tier that yields any match decides the result:
|
|
192
|
+
* - exactly one match with an email → `found`
|
|
193
|
+
* - exactly one match, no email → `no_email`
|
|
194
|
+
* - more than one match → `ambiguous` (caller disambiguates)
|
|
195
|
+
* - no match in any tier → `not_found`
|
|
196
|
+
*/
|
|
197
|
+
export function resolveNameToEmail(
|
|
198
|
+
people: PersonRecord[],
|
|
199
|
+
name: string,
|
|
200
|
+
): ResolveResult {
|
|
201
|
+
const query = name.trim();
|
|
202
|
+
if (!query) return { status: "not_found" };
|
|
203
|
+
const lowered = query.toLowerCase();
|
|
204
|
+
|
|
205
|
+
const exactName = people.filter((p) => p.name.toLowerCase() === lowered);
|
|
206
|
+
const exactSlug = people.filter((p) => p.slug.toLowerCase() === lowered);
|
|
207
|
+
const substring = searchPeople(people, query);
|
|
208
|
+
|
|
209
|
+
const matches =
|
|
210
|
+
exactName.length > 0
|
|
211
|
+
? exactName
|
|
212
|
+
: exactSlug.length > 0
|
|
213
|
+
? exactSlug
|
|
214
|
+
: substring;
|
|
215
|
+
|
|
216
|
+
if (matches.length === 0) return { status: "not_found" };
|
|
217
|
+
if (matches.length > 1) return { status: "ambiguous", matches };
|
|
218
|
+
|
|
219
|
+
const person = matches[0];
|
|
220
|
+
if (!person.email) return { status: "no_email", person };
|
|
221
|
+
return { status: "found", email: person.email, person };
|
|
222
|
+
}
|