@picahq/cli 0.1.0 → 0.3.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.
@@ -1,73 +0,0 @@
1
- import type { Platform } from './types.js';
2
-
3
- export function findPlatform(platforms: Platform[], query: string): Platform | null {
4
- const normalizedQuery = query.toLowerCase().trim();
5
-
6
- // Exact match first
7
- const exact = platforms.find(
8
- p => p.platform.toLowerCase() === normalizedQuery || p.name.toLowerCase() === normalizedQuery
9
- );
10
- if (exact) return exact;
11
-
12
- return null;
13
- }
14
-
15
- export function findSimilarPlatforms(platforms: Platform[], query: string, limit = 3): Platform[] {
16
- const normalizedQuery = query.toLowerCase().trim();
17
-
18
- // Simple similarity: platforms that contain the query or query contains part of platform
19
- const scored = platforms
20
- .map(p => {
21
- const name = p.name.toLowerCase();
22
- const slug = p.platform.toLowerCase();
23
-
24
- let score = 0;
25
- if (name.includes(normalizedQuery) || slug.includes(normalizedQuery)) {
26
- score = 10;
27
- } else if (normalizedQuery.includes(name) || normalizedQuery.includes(slug)) {
28
- score = 5;
29
- } else {
30
- // Levenshtein-lite: count matching characters
31
- score = countMatchingChars(normalizedQuery, slug);
32
- }
33
-
34
- return { platform: p, score };
35
- })
36
- .filter(item => item.score > 0)
37
- .sort((a, b) => b.score - a.score)
38
- .slice(0, limit);
39
-
40
- return scored.map(item => item.platform);
41
- }
42
-
43
- function countMatchingChars(a: string, b: string): number {
44
- let count = 0;
45
- const bChars = new Set(b.split(''));
46
- for (const char of a) {
47
- if (bChars.has(char)) count++;
48
- }
49
- return count;
50
- }
51
-
52
- export function formatPlatformList(platforms: Platform[]): string {
53
- const byCategory = new Map<string, Platform[]>();
54
-
55
- for (const p of platforms) {
56
- const category = p.category || 'Other';
57
- if (!byCategory.has(category)) {
58
- byCategory.set(category, []);
59
- }
60
- byCategory.get(category)!.push(p);
61
- }
62
-
63
- const lines: string[] = [];
64
- const sortedCategories = [...byCategory.keys()].sort();
65
-
66
- for (const category of sortedCategories) {
67
- const categoryPlatforms = byCategory.get(category)!;
68
- const names = categoryPlatforms.map(p => p.platform).sort().join(', ');
69
- lines.push(` ${category}: ${names}`);
70
- }
71
-
72
- return lines.join('\n');
73
- }
package/src/lib/table.ts DELETED
@@ -1,60 +0,0 @@
1
- import pc from 'picocolors';
2
-
3
- interface Column {
4
- key: string;
5
- label: string;
6
- align?: 'left' | 'right';
7
- color?: (value: string) => string;
8
- }
9
-
10
- /**
11
- * Print a formatted table to stdout.
12
- * Automatically sizes columns to content with a 2-space gap.
13
- */
14
- export function printTable(columns: Column[], rows: Record<string, string>[]): void {
15
- if (rows.length === 0) return;
16
-
17
- const gap = ' ';
18
- const indent = ' ';
19
-
20
- // Calculate column widths (max of header and all values, using raw string length)
21
- const widths = columns.map(col => {
22
- const headerLen = col.label.length;
23
- const maxValueLen = Math.max(...rows.map(row => stripAnsi(row[col.key] || '').length));
24
- return Math.max(headerLen, maxValueLen);
25
- });
26
-
27
- // Header
28
- const header = columns.map((col, i) => {
29
- const padded = col.align === 'right'
30
- ? col.label.padStart(widths[i])
31
- : col.label.padEnd(widths[i]);
32
- return pc.dim(padded);
33
- }).join(gap);
34
- console.log(`${indent}${header}`);
35
-
36
- // Separator
37
- const separator = columns.map((_, i) => pc.dim('─'.repeat(widths[i]))).join(gap);
38
- console.log(`${indent}${separator}`);
39
-
40
- // Rows
41
- for (const row of rows) {
42
- const line = columns.map((col, i) => {
43
- const raw = row[col.key] || '';
44
- const rawLen = stripAnsi(raw).length;
45
- const padding = widths[i] - rawLen;
46
- const colored = col.color ? col.color(raw) : raw;
47
-
48
- if (col.align === 'right') {
49
- return ' '.repeat(Math.max(0, padding)) + colored;
50
- }
51
- return colored + ' '.repeat(Math.max(0, padding));
52
- }).join(gap);
53
- console.log(`${indent}${line}`);
54
- }
55
- }
56
-
57
- // Strip ANSI escape codes for length calculation
58
- function stripAnsi(str: string): string {
59
- return str.replace(/\x1b\[[0-9;]*m/g, '');
60
- }
package/src/lib/types.ts DELETED
@@ -1,89 +0,0 @@
1
- export interface Agent {
2
- id: string;
3
- name: string;
4
- configPath: string;
5
- configKey: string;
6
- detectDir: string;
7
- projectConfigPath?: string;
8
- }
9
-
10
- export interface Connection {
11
- id: string;
12
- platform: string;
13
- key: string;
14
- state: 'operational' | 'degraded' | 'failed' | 'unknown';
15
- createdAt?: string;
16
- }
17
-
18
- export interface Platform {
19
- id: number;
20
- name: string;
21
- key: string;
22
- platform: string;
23
- category: string;
24
- description?: string;
25
- status?: string;
26
- oauth?: boolean;
27
- }
28
-
29
- export interface PlatformsResponse {
30
- rows: Platform[];
31
- total: number;
32
- pages: number;
33
- page: number;
34
- }
35
-
36
- export interface Config {
37
- apiKey: string;
38
- installedAgents: string[];
39
- createdAt: string;
40
- }
41
-
42
- export interface ConnectionsResponse {
43
- rows: Connection[];
44
- total: number;
45
- pages: number;
46
- page: number;
47
- }
48
-
49
- export interface PlatformAction {
50
- _id: string;
51
- title: string;
52
- key: string;
53
- method: string;
54
- path: string;
55
- tags: string[];
56
- connectionPlatform?: string;
57
- }
58
-
59
- export interface ActionKnowledge {
60
- _id: string;
61
- connectionPlatform: string;
62
- title: string;
63
- path: string;
64
- knowledge: string;
65
- method: string;
66
- baseUrl: string;
67
- tags: string[];
68
- active: boolean;
69
- }
70
-
71
- export interface KnowledgeResponse {
72
- rows: ActionKnowledge[];
73
- }
74
-
75
- export interface ActionsSearchResponse {
76
- rows: PlatformAction[];
77
- total: number;
78
- pages: number;
79
- page: number;
80
- }
81
-
82
- export interface ExecuteResponse {
83
- success: boolean;
84
- responseData?: unknown;
85
- requestConfig?: unknown;
86
- platform?: string;
87
- action?: string;
88
- error?: string;
89
- }