@pachca/cli 2026.5.0 → 2026.5.2
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/CHANGELOG.md +12 -0
- package/README.md +17 -14
- package/README.template.md +3 -3
- package/dist/api-introspect.js +60 -0
- package/dist/base-command.js +5 -0
- package/dist/commands/api.js +89 -7
- package/dist/commands/auth/login.js +2 -2
- package/dist/commands/auth/logout.js +1 -1
- package/dist/commands/auth/switch.js +1 -1
- package/dist/commands/bots/list-events.js +9 -2
- package/dist/commands/chats/list.js +9 -2
- package/dist/commands/commands.js +1 -1
- package/dist/commands/config/get.js +1 -1
- package/dist/commands/config/set.js +2 -2
- package/dist/commands/group-tags/list-users.js +9 -2
- package/dist/commands/group-tags/list.js +9 -2
- package/dist/commands/guide.js +1 -1
- package/dist/commands/introspect.js +6 -44
- package/dist/commands/members/list.js +9 -2
- package/dist/commands/messages/list.js +9 -2
- package/dist/commands/reactions/list.js +9 -2
- package/dist/commands/read-member/list-readers.js +9 -2
- package/dist/commands/search/list-chats.js +9 -2
- package/dist/commands/search/list-messages.js +9 -2
- package/dist/commands/search/list-users.js +9 -2
- package/dist/commands/security/list.js +9 -2
- package/dist/commands/tasks/list.js +9 -2
- package/dist/commands/users/create.js +4 -0
- package/dist/commands/users/list.js +9 -2
- package/dist/data/changelog.json +39 -0
- package/dist/data/endpoints.json +1 -0
- package/dist/data/workflows.json +16 -0
- package/dist/lib/manifest.js +72 -0
- package/dist/output.js +31 -0
- package/dist/profiles.js +6 -0
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
package/dist/data/workflows.json
CHANGED
|
@@ -522,6 +522,22 @@
|
|
|
522
522
|
}
|
|
523
523
|
]
|
|
524
524
|
},
|
|
525
|
+
{
|
|
526
|
+
"title": "Создать гостя в чат",
|
|
527
|
+
"skill": "pachca-users",
|
|
528
|
+
"steps": [
|
|
529
|
+
{
|
|
530
|
+
"description": "Выбери активный чат, в который добавить гостя — узнай его ID",
|
|
531
|
+
"command": "pachca chats list",
|
|
532
|
+
"notes": "Чат должен быть активным (не архивным) и принадлежать вашей компании. У токена должно быть право добавлять в него участников."
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
"description": "Создай гостя: роль `guest` и ровно один чат в `--chat-ids`",
|
|
536
|
+
"command": "pachca users create --email=\"guest@example.com\" --role=guest --chat-ids='[12345]'",
|
|
537
|
+
"notes": "Для роли `guest` `chat_ids` обязателен и должен содержать ровно один чат. Нарушение (не передан, пусто, больше одного, чат не существует, архивный или нет прав) → `400` с элементом `errors`, где `key` — `chat_ids`."
|
|
538
|
+
}
|
|
539
|
+
]
|
|
540
|
+
},
|
|
525
541
|
{
|
|
526
542
|
"title": "Найти сотрудника по имени или email",
|
|
527
543
|
"skill": "pachca-users",
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* D2 — single oclif.manifest.json parsing/normalization logic.
|
|
3
|
+
*
|
|
4
|
+
* Used by both the `introspect` command (runtime) and the build-time
|
|
5
|
+
* commands.json emitter (scripts/emit-commands.ts) that feeds the docs
|
|
6
|
+
* Commands page. One source of data (oclif.manifest.json), one parsing
|
|
7
|
+
* logic — no second implementation in the docs component.
|
|
8
|
+
*/
|
|
9
|
+
/** `pachca introspect` (no arg) — list every command with metadata. */
|
|
10
|
+
export function listCommandEntries(commands) {
|
|
11
|
+
return Object.entries(commands).map(([id, meta]) => ({
|
|
12
|
+
command: `pachca ${id.replace(/:/g, ' ')}`,
|
|
13
|
+
summary: (meta.summary || meta.description || ''),
|
|
14
|
+
method: (meta.apiMethod || null),
|
|
15
|
+
path: (meta.apiPath || null),
|
|
16
|
+
scope: (meta.scope || null),
|
|
17
|
+
plan: (meta.plan || null),
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
/** `pachca introspect <command>` — full metadata for one command. */
|
|
21
|
+
export function normalizeCommand(commandId, cmdMeta, baseFlagNames) {
|
|
22
|
+
const requiredFlagNames = new Set(cmdMeta.requiredFlags || []);
|
|
23
|
+
const flagsMeta = cmdMeta.flags;
|
|
24
|
+
const flags = flagsMeta
|
|
25
|
+
? Object.entries(flagsMeta)
|
|
26
|
+
.filter(([name]) => !baseFlagNames.has(name))
|
|
27
|
+
.map(([name, meta]) => ({
|
|
28
|
+
name,
|
|
29
|
+
type: (meta.type || 'string'),
|
|
30
|
+
required: requiredFlagNames.has(name),
|
|
31
|
+
description: (meta.description || ''),
|
|
32
|
+
...(meta.options ? { options: meta.options } : {}),
|
|
33
|
+
...(meta.maxLength ? { maxLength: meta.maxLength } : {}),
|
|
34
|
+
}))
|
|
35
|
+
: [];
|
|
36
|
+
const argsMeta = cmdMeta.args;
|
|
37
|
+
const args = argsMeta
|
|
38
|
+
? Object.entries(argsMeta).map(([name, meta]) => ({
|
|
39
|
+
name,
|
|
40
|
+
required: (meta.required || false),
|
|
41
|
+
description: (meta.description || ''),
|
|
42
|
+
}))
|
|
43
|
+
: [];
|
|
44
|
+
return {
|
|
45
|
+
command: `pachca ${commandId.replace(/:/g, ' ')}`,
|
|
46
|
+
summary: (cmdMeta.summary || cmdMeta.description || ''),
|
|
47
|
+
method: (cmdMeta.apiMethod || null),
|
|
48
|
+
path: (cmdMeta.apiPath || null),
|
|
49
|
+
scope: (cmdMeta.scope || null),
|
|
50
|
+
plan: (cmdMeta.plan || null),
|
|
51
|
+
...(args.length > 0 ? { args } : {}),
|
|
52
|
+
flags,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Group every command by its topic/section (the part before the first ':',
|
|
57
|
+
* e.g. "messages:create" → "messages"; "doctor" → "doctor"). Used by the
|
|
58
|
+
* build-time emitter for the docs Commands page.
|
|
59
|
+
*/
|
|
60
|
+
export function groupCommandsBySection(commands, baseFlagNames) {
|
|
61
|
+
const bySection = new Map();
|
|
62
|
+
for (const [id, meta] of Object.entries(commands)) {
|
|
63
|
+
const section = id.includes(':') ? id.split(':')[0] : id;
|
|
64
|
+
const normalized = normalizeCommand(id, meta, baseFlagNames);
|
|
65
|
+
if (!bySection.has(section))
|
|
66
|
+
bySection.set(section, []);
|
|
67
|
+
bySection.get(section).push(normalized);
|
|
68
|
+
}
|
|
69
|
+
return [...bySection.entries()]
|
|
70
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
71
|
+
.map(([section, cmds]) => ({ section, commands: cmds }));
|
|
72
|
+
}
|
package/dist/output.js
CHANGED
|
@@ -7,6 +7,11 @@ import { stringify as yamlStringify } from 'yaml';
|
|
|
7
7
|
export function outputData(data, opts) {
|
|
8
8
|
if (opts.quiet)
|
|
9
9
|
return;
|
|
10
|
+
// C7 — named plain mode (additive; existing formats untouched).
|
|
11
|
+
if (opts.plain) {
|
|
12
|
+
outputPlain(data, opts);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
10
15
|
const format = opts.format;
|
|
11
16
|
if (format === 'json') {
|
|
12
17
|
outputJson(data);
|
|
@@ -49,6 +54,32 @@ function outputCsv(data, opts) {
|
|
|
49
54
|
process.stdout.write(row.join(',') + '\n');
|
|
50
55
|
}
|
|
51
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* C7 — plain mode. Variant of outputCsv for scripts: TSV, no header,
|
|
59
|
+
* `id` column first (if present), no color, no truncation. Same column
|
|
60
|
+
* selection as csv/table (OutputOptions.columns). Tabs/newlines inside
|
|
61
|
+
* values are collapsed to spaces so every record stays on one line
|
|
62
|
+
* (safe for cut/awk).
|
|
63
|
+
*/
|
|
64
|
+
function outputPlain(data, opts) {
|
|
65
|
+
const items = Array.isArray(data) ? data : [data];
|
|
66
|
+
if (items.length === 0)
|
|
67
|
+
return;
|
|
68
|
+
let columns = opts.columns || Object.keys(items[0]);
|
|
69
|
+
if (!opts.columns && columns.includes('id')) {
|
|
70
|
+
columns = ['id', ...columns.filter((c) => c !== 'id')];
|
|
71
|
+
}
|
|
72
|
+
for (const item of items) {
|
|
73
|
+
const row = columns.map((col) => {
|
|
74
|
+
const val = item[col];
|
|
75
|
+
if (val == null)
|
|
76
|
+
return '';
|
|
77
|
+
const str = typeof val === 'object' ? JSON.stringify(val) : String(val);
|
|
78
|
+
return str.replace(/[\t\n\r]+/g, ' ');
|
|
79
|
+
});
|
|
80
|
+
process.stdout.write(row.join('\t') + '\n');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
52
83
|
function outputTable(data, opts) {
|
|
53
84
|
const items = Array.isArray(data) ? data : [data];
|
|
54
85
|
if (items.length === 0) {
|
package/dist/profiles.js
CHANGED
|
@@ -4,6 +4,12 @@ import * as os from 'node:os';
|
|
|
4
4
|
import * as TOML from 'smol-toml';
|
|
5
5
|
const CONFIG_FILENAME = 'config.toml';
|
|
6
6
|
function getConfigDir() {
|
|
7
|
+
// C8 — explicit override (highest priority). Guarded: when PACHCA_HOME is
|
|
8
|
+
// unset the path is byte-identical to before, so existing behavior is
|
|
9
|
+
// preserved. Useful for isolating config in CI/tests/agents.
|
|
10
|
+
if (process.env.PACHCA_HOME) {
|
|
11
|
+
return path.join(process.env.PACHCA_HOME, 'pachca');
|
|
12
|
+
}
|
|
7
13
|
// XDG_CONFIG_HOME on Unix, LOCALAPPDATA on Windows
|
|
8
14
|
if (process.env.XDG_CONFIG_HOME) {
|
|
9
15
|
return path.join(process.env.XDG_CONFIG_HOME, 'pachca');
|