workplace-pua-cli 0.4.1 → 0.8.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/LICENSE +21 -0
- package/README.md +512 -243
- package/dist/commands/chat-new-imports.js +2 -0
- package/dist/commands/config.js +14 -6
- package/dist/commands/email.js +301 -0
- package/dist/commands/interview.js +660 -0
- package/dist/commands/jargon.js +153 -0
- package/dist/commands/meeting-room.js +384 -0
- package/dist/commands/meeting.js +323 -0
- package/dist/commands/weekly.js +302 -0
- package/dist/index.js +29 -7
- package/dist/prompts/hr.js +126 -0
- package/dist/prompts/index.js +82 -1
- package/dist/prompts/intern.js +126 -0
- package/dist/prompts/interview-prompts.js +286 -0
- package/dist/prompts/meeting-prompts.js +229 -0
- package/dist/prompts/pm.js +123 -0
- package/dist/prompts/techlead.js +126 -0
- package/dist/utils/box.js +141 -0
- package/dist/utils/meeting-utils.js +194 -0
- package/dist/utils/resume-parser.js +122 -0
- package/dist/utils/stream.js +97 -13
- package/dist/utils/theme.js +177 -0
- package/package.json +73 -52
- package/.env.example +0 -4
- package/.eslintrc.json +0 -21
- package/.prettierrc.json +0 -9
- package/CHANGELOG.md +0 -113
- package/docs/OPTIMIZATION.md +0 -772
- package/docs/TECHNICAL_PRINCIPLES.md +0 -663
- package/sample/1.png +0 -0
- package/sample/2.png +0 -0
- package/screenshots/chat-dialogue.png +0 -0
- package/screenshots/chat-mode.png +0 -0
- package/src/__tests__/config/settings.test.ts +0 -48
- package/src/__tests__/prompts/boss.test.ts +0 -35
- package/src/commands/chat.ts +0 -328
- package/src/commands/config.ts +0 -283
- package/src/commands/prompt.ts +0 -154
- package/src/config/providers.ts +0 -109
- package/src/config/session-storage.ts +0 -94
- package/src/config/settings.ts +0 -194
- package/src/config/storage.ts +0 -150
- package/src/history/session.ts +0 -141
- package/src/index.ts +0 -164
- package/src/llm/base.ts +0 -55
- package/src/llm/factory.ts +0 -24
- package/src/llm/openai.ts +0 -113
- package/src/llm/zhipu.ts +0 -101
- package/src/prompts/boss.ts +0 -43
- package/src/prompts/employee.ts +0 -43
- package/src/prompts/index.ts +0 -3
- package/src/utils/formatter.ts +0 -104
- package/src/utils/logger.ts +0 -31
- package/src/utils/stream.ts +0 -76
- package/tsconfig.json +0 -20
- package/vitest.config.ts +0 -18
package/src/utils/formatter.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
export type OutputFormat = 'text' | 'markdown' | 'json';
|
|
4
|
-
|
|
5
|
-
export interface FormattedOutput {
|
|
6
|
-
format: OutputFormat;
|
|
7
|
-
content: string;
|
|
8
|
-
metadata?: {
|
|
9
|
-
role?: string;
|
|
10
|
-
severity?: string;
|
|
11
|
-
provider?: string;
|
|
12
|
-
model?: string;
|
|
13
|
-
tokens?: number;
|
|
14
|
-
timestamp?: string;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class OutputFormatter {
|
|
19
|
-
private outputFormat: OutputFormat;
|
|
20
|
-
|
|
21
|
-
constructor(format: OutputFormat = 'text') {
|
|
22
|
-
this.outputFormat = format;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
format(data: FormattedOutput): string {
|
|
26
|
-
switch (this.outputFormat) {
|
|
27
|
-
case 'json':
|
|
28
|
-
return this.formatJson(data);
|
|
29
|
-
case 'markdown':
|
|
30
|
-
return this.formatMarkdown(data);
|
|
31
|
-
case 'text':
|
|
32
|
-
default:
|
|
33
|
-
return this.formatText(data);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private formatJson(data: FormattedOutput): string {
|
|
38
|
-
return JSON.stringify({
|
|
39
|
-
output: data.content,
|
|
40
|
-
metadata: data.metadata || {},
|
|
41
|
-
timestamp: new Date().toISOString()
|
|
42
|
-
}, null, 2);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private formatMarkdown(data: FormattedOutput): string {
|
|
46
|
-
let result = '';
|
|
47
|
-
|
|
48
|
-
if (data.metadata?.role) {
|
|
49
|
-
result += `## ${data.metadata.role}\n\n`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
result += data.content;
|
|
53
|
-
result += '\n';
|
|
54
|
-
|
|
55
|
-
if (data.metadata) {
|
|
56
|
-
result += '\n---\n\n';
|
|
57
|
-
result += '### Metadata\n\n';
|
|
58
|
-
result += '| Key | Value |\n';
|
|
59
|
-
result += '|-----|-------|\n';
|
|
60
|
-
|
|
61
|
-
for (const [key, value] of Object.entries(data.metadata)) {
|
|
62
|
-
result += `| ${key} | ${value} |\n`;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private formatText(data: FormattedOutput): string {
|
|
70
|
-
return data.content;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
print(data: FormattedOutput): void {
|
|
74
|
-
const formatted = this.format(data);
|
|
75
|
-
|
|
76
|
-
switch (this.outputFormat) {
|
|
77
|
-
case 'json':
|
|
78
|
-
console.log(formatted);
|
|
79
|
-
break;
|
|
80
|
-
case 'markdown':
|
|
81
|
-
console.log(formatted);
|
|
82
|
-
break;
|
|
83
|
-
case 'text':
|
|
84
|
-
default:
|
|
85
|
-
// 对于文本格式,处理颜色
|
|
86
|
-
if (data.metadata?.role === 'boss') {
|
|
87
|
-
console.log(chalk.red(formatted));
|
|
88
|
-
} else if (data.metadata?.role === 'employee') {
|
|
89
|
-
console.log(chalk.yellow(formatted));
|
|
90
|
-
} else {
|
|
91
|
-
console.log(formatted);
|
|
92
|
-
}
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
setFormat(format: OutputFormat): void {
|
|
98
|
-
this.outputFormat = format;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
getFormat(): OutputFormat {
|
|
102
|
-
return this.outputFormat;
|
|
103
|
-
}
|
|
104
|
-
}
|
package/src/utils/logger.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
export class Logger {
|
|
4
|
-
info(message: string): void {
|
|
5
|
-
console.log(chalk.blue('ℹ'), message);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
success(message: string): void {
|
|
9
|
-
console.log(chalk.green('✓'), message);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
warning(message: string): void {
|
|
13
|
-
console.log(chalk.yellow('⚠'), message);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
error(message: string): void {
|
|
17
|
-
console.error(chalk.red('✗'), message);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
debug(message: string): void {
|
|
21
|
-
if (process.env.DEBUG) {
|
|
22
|
-
console.log(chalk.gray('…'), message);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
system(message: string): void {
|
|
27
|
-
console.log(chalk.cyan('►'), message);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const logger = new Logger();
|
package/src/utils/stream.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { StreamChunk } from '../llm/base';
|
|
3
|
-
|
|
4
|
-
export class StreamPrinter {
|
|
5
|
-
private buffer: string = '';
|
|
6
|
-
private currentLine: string = '';
|
|
7
|
-
|
|
8
|
-
constructor(private readonly roleColor: (text: string) => string = chalk.green) {}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Print a streaming chunk to the terminal
|
|
12
|
-
*/
|
|
13
|
-
printChunk(chunk: StreamChunk): void {
|
|
14
|
-
if (chunk.content) {
|
|
15
|
-
// Accumulate content for smoother display
|
|
16
|
-
this.buffer += chunk.content;
|
|
17
|
-
|
|
18
|
-
// Print directly for real-time effect
|
|
19
|
-
process.stdout.write(chunk.content);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (chunk.done) {
|
|
23
|
-
// Add newline when done
|
|
24
|
-
process.stdout.write('\n');
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Print a complete message (non-streaming)
|
|
30
|
-
*/
|
|
31
|
-
printMessage(message: string): void {
|
|
32
|
-
console.log(this.roleColor(message));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Print user input
|
|
37
|
-
*/
|
|
38
|
-
printUserInput(input: string): void {
|
|
39
|
-
console.log(chalk.gray('┌─────────────────────────────────────'));
|
|
40
|
-
console.log(chalk.gray('│ 你:'), input);
|
|
41
|
-
console.log(chalk.gray('└─────────────────────────────────────'));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Print assistant response header
|
|
46
|
-
*/
|
|
47
|
-
printResponseHeader(role: string): void {
|
|
48
|
-
const roleLabel = role === 'boss' ? '老板' : '员工';
|
|
49
|
-
const color = role === 'boss' ? chalk.red.bold : chalk.yellow.bold;
|
|
50
|
-
console.log();
|
|
51
|
-
console.log(color(`┌─ ${roleLabel} ─────────────────────────────`));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Print assistant response footer
|
|
56
|
-
*/
|
|
57
|
-
printResponseFooter(): void {
|
|
58
|
-
console.log(chalk.gray('└─────────────────────────────────────'));
|
|
59
|
-
console.log();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Print error message
|
|
64
|
-
*/
|
|
65
|
-
printError(message: string): void {
|
|
66
|
-
console.error(chalk.red('✗ 错误:'), message);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Clear current line
|
|
71
|
-
*/
|
|
72
|
-
clearLine(): void {
|
|
73
|
-
process.stdout.clearLine(0);
|
|
74
|
-
process.stdout.cursorTo(0);
|
|
75
|
-
}
|
|
76
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "CommonJS",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"lib": ["ES2022"],
|
|
7
|
-
"outDir": "./dist",
|
|
8
|
-
"rootDir": "./src",
|
|
9
|
-
"strict": false,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
"resolveJsonModule": true,
|
|
14
|
-
"declaration": false,
|
|
15
|
-
"sourceMap": false,
|
|
16
|
-
"types": ["node"]
|
|
17
|
-
},
|
|
18
|
-
"include": ["src/**/*"],
|
|
19
|
-
"exclude": ["node_modules", "dist", "**/*.test.ts"]
|
|
20
|
-
}
|
package/vitest.config.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vitest/config';
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
test: {
|
|
5
|
-
globals: {
|
|
6
|
-
describe: 'readonly',
|
|
7
|
-
it: 'readonly',
|
|
8
|
-
expect: 'readonly'
|
|
9
|
-
},
|
|
10
|
-
environment: 'node',
|
|
11
|
-
include: ['src/**/*.test.ts', 'tests/**/*.test.ts'],
|
|
12
|
-
coverage: {
|
|
13
|
-
provider: 'v8',
|
|
14
|
-
reporter: ['text', 'json', 'html'],
|
|
15
|
-
exclude: ['**/*.test.ts', '**/dist/**']
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
});
|