@aibyzero/byz 0.1.6 → 0.1.7
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 +11 -0
- package/dist/cli.js +3 -16
- package/dist/conversation/conversation-extension.js +85 -0
- package/dist/conversation/interaction-policy.js +53 -0
- package/dist/conversation/routing-policy.js +102 -0
- package/dist/runtime/bundle/chunks/{chunk-SKWR5IN4.js → chunk-JDLZZASY.js} +7 -7
- package/dist/runtime/bundle/cli.js +1 -1
- package/dist/runtime/bundle/index.js +1 -1
- package/dist/runtime/bundle/rpc-entry.js +1 -1
- package/dist/runtime/config.d.ts.map +1 -1
- package/dist/runtime/config.js +3 -3
- package/dist/runtime/config.js.map +1 -1
- package/dist/runtime/core/extensions/index.d.ts +1 -1
- package/dist/runtime/core/extensions/index.d.ts.map +1 -1
- package/dist/runtime/core/extensions/index.js.map +1 -1
- package/dist/runtime/core/extensions/runner.d.ts.map +1 -1
- package/dist/runtime/core/extensions/runner.js +3 -0
- package/dist/runtime/core/extensions/runner.js.map +1 -1
- package/dist/runtime/core/extensions/types.d.ts +17 -0
- package/dist/runtime/core/extensions/types.d.ts.map +1 -1
- package/dist/runtime/core/extensions/types.js.map +1 -1
- package/dist/runtime/modes/interactive/interactive-mode.d.ts +5 -0
- package/dist/runtime/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/runtime/modes/interactive/interactive-mode.js +59 -6
- package/dist/runtime/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/runtime/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/runtime/modes/rpc/rpc-mode.js +9 -0
- package/dist/runtime/modes/rpc/rpc-mode.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.1.7 - 2026-08-29
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Added same-session routing and collaboration preferences that classify common requests, inject minimal per-turn guidance, and show route details only on demand.
|
|
10
|
+
- Added the default BYZ conversation shell with a goal-first welcome, low-noise progress, on-demand details, and natural-language confirmation input.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Changed the default interactive shell to hide internal resources, tool rows, model metadata, and advanced controls until requested.
|
|
15
|
+
|
|
5
16
|
## 0.1.6 - 2026-08-28
|
|
6
17
|
|
|
7
18
|
### Added
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import { createConversationExtension } from "./conversation/conversation-extension.js";
|
|
3
4
|
import { createFastSessionController, prepareFastRuntimeArgs, selectFastRuntimeArgs } from "./fast.js";
|
|
4
5
|
import { createPrewalkExtension } from "./prewalk.js";
|
|
5
6
|
import { main } from "./runtime/bundle/index.js";
|
|
@@ -25,16 +26,6 @@ try {
|
|
|
25
26
|
const fastRuntime = prepareFastRuntimeArgs(args);
|
|
26
27
|
const parsedWorkflow = parseWorkflowOption(fastRuntime.commandArgs);
|
|
27
28
|
const commandArgs = parsedWorkflow.forwardedArgs;
|
|
28
|
-
const isRootHelp = commandArgs.length === 1 && (commandArgs[0] === "--help" || commandArgs[0] === "-h");
|
|
29
|
-
if (isRootHelp) {
|
|
30
|
-
console.error("BYZ updates: byz update (npm-managed global installations only)");
|
|
31
|
-
console.error("BYZ Fast: --fast (thinking=low; optional model: BYZ_FAST_MODEL)");
|
|
32
|
-
console.error("BYZ Prewalk: /prewalk (one-time handoff after the first successful workspace edit/write)");
|
|
33
|
-
console.error("BYZ workflows: --workflow <cm|cm-plugin|none> (default: BYZ_WORKFLOW or cm)");
|
|
34
|
-
console.error(
|
|
35
|
-
"Commands: byz workflow list | byz workflow status [cm|cm-plugin|none] | byz workflow check <cm|cm-plugin>",
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
29
|
|
|
39
30
|
if (await handleWorkflowCommand(commandArgs, { workflowId: parsedWorkflow.workflowId })) {
|
|
40
31
|
// BYZ-owned command handled without starting the Pi runtime.
|
|
@@ -47,12 +38,6 @@ try {
|
|
|
47
38
|
stdoutIsTTY: process.stdout.isTTY,
|
|
48
39
|
});
|
|
49
40
|
const runtimeArgs = selectFastRuntimeArgs(fastRuntime, { isInteractive, loadWorkflow });
|
|
50
|
-
if (fastRuntime.enabled && loadWorkflow && isInteractive) {
|
|
51
|
-
console.error(
|
|
52
|
-
`BYZ Fast: model=${fastRuntime.model}, thinking=${fastRuntime.thinking}, workflow=${parsedWorkflow.workflowId}`,
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
41
|
if (loadWorkflow && isInteractive) {
|
|
57
42
|
const parsedRuntimeWorkflow = parseWorkflowOption(runtimeArgs);
|
|
58
43
|
const resolveResources = (workflowId) =>
|
|
@@ -68,7 +53,9 @@ try {
|
|
|
68
53
|
initialUseLowThinking: fastRuntime.useLowThinking,
|
|
69
54
|
});
|
|
70
55
|
const prewalkExtension = createPrewalkExtension({ fastController });
|
|
56
|
+
const conversationExtension = createConversationExtension();
|
|
71
57
|
const byzExtension = (pi) => {
|
|
58
|
+
conversationExtension(pi);
|
|
72
59
|
workflowExtension(pi);
|
|
73
60
|
fastController.extension(pi);
|
|
74
61
|
prewalkExtension(pi);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { createInteractionPolicy, formatDecision, parseConversationControl } from "./interaction-policy.js";
|
|
2
|
+
import { createRoutingPolicy } from "./routing-policy.js";
|
|
3
|
+
|
|
4
|
+
const WELCOME = "BYZ\n\n你想让我帮你做什么?";
|
|
5
|
+
|
|
6
|
+
export function createConversationExtension() {
|
|
7
|
+
const policy = createInteractionPolicy();
|
|
8
|
+
const routingPolicy = createRoutingPolicy();
|
|
9
|
+
|
|
10
|
+
return function conversationExtension(pi) {
|
|
11
|
+
let progressTimer;
|
|
12
|
+
|
|
13
|
+
function clearProgressTimer() {
|
|
14
|
+
if (progressTimer) clearTimeout(progressTimer);
|
|
15
|
+
progressTimer = undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
pi.on("session_start", (_event, ctx) => {
|
|
19
|
+
routingPolicy.reset();
|
|
20
|
+
ctx.ui.setTitle?.("BYZ");
|
|
21
|
+
ctx.ui.setMessagePresenter?.((message) => policy.presentAssistantMessage(message));
|
|
22
|
+
ctx.ui.setToolExecutionVisible?.(false);
|
|
23
|
+
ctx.ui.setFooter?.(() => ({
|
|
24
|
+
invalidate() {},
|
|
25
|
+
render() {
|
|
26
|
+
return [];
|
|
27
|
+
},
|
|
28
|
+
}));
|
|
29
|
+
ctx.ui.setConfirmationPresenter?.(async ({ title, message, confirm }) => {
|
|
30
|
+
const prompt = formatDecision({
|
|
31
|
+
impact: message,
|
|
32
|
+
recommendation: "确认",
|
|
33
|
+
alternative: "取消",
|
|
34
|
+
onReject: "不会执行此操作",
|
|
35
|
+
});
|
|
36
|
+
const answer = await ctx.ui.input(prompt, `${title}:输入“确认”或“取消”`);
|
|
37
|
+
const choice = answer ? parseConversationControl(answer) : undefined;
|
|
38
|
+
if (choice === "accept" || choice === "proceed") return true;
|
|
39
|
+
if (choice === "reject") return false;
|
|
40
|
+
return confirm();
|
|
41
|
+
});
|
|
42
|
+
ctx.ui.notify(WELCOME, "info");
|
|
43
|
+
});
|
|
44
|
+
pi.on("agent_start", (_event, ctx) => {
|
|
45
|
+
policy.resetProgress();
|
|
46
|
+
clearProgressTimer();
|
|
47
|
+
progressTimer = setTimeout(() => {
|
|
48
|
+
const message = policy.present("progress", "");
|
|
49
|
+
if (message) ctx.ui.setWorkingMessage?.(message);
|
|
50
|
+
}, 30_000);
|
|
51
|
+
});
|
|
52
|
+
pi.on("agent_end", () => {
|
|
53
|
+
clearProgressTimer();
|
|
54
|
+
});
|
|
55
|
+
pi.on("session_shutdown", () => {
|
|
56
|
+
routingPolicy.reset();
|
|
57
|
+
clearProgressTimer();
|
|
58
|
+
});
|
|
59
|
+
function showDetails(ctx) {
|
|
60
|
+
policy.setDetailEnabled(true);
|
|
61
|
+
ctx.ui.setToolExecutionVisible?.(true);
|
|
62
|
+
ctx.ui.notify("已展开细节。高级控制:/fast、/prewalk、/workflow。", "info");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
pi.registerCommand("details", {
|
|
66
|
+
description: "Show BYZ advanced controls",
|
|
67
|
+
handler: async (_args, ctx) => showDetails(ctx),
|
|
68
|
+
});
|
|
69
|
+
pi.on("before_agent_start", async (event, ctx) => {
|
|
70
|
+
const route = routingPolicy.route(event.prompt);
|
|
71
|
+
if (route.details || parseConversationControl(event.prompt) === "detail") showDetails(ctx);
|
|
72
|
+
if (policy.isDetailEnabled()) {
|
|
73
|
+
ctx.ui.notify(
|
|
74
|
+
`当前类别:${route.kind}。当前偏好:主动程度 ${route.preferences.autonomy},交付 ${route.preferences.delivery}。`,
|
|
75
|
+
"info",
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
systemPrompt: `${event.systemPrompt ?? ""}\n\nBYZ collaboration guidance for this turn:\n${route.instructions}`,
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { WELCOME };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const INTERNAL_TERMS = /\b(?:model|skill|workflow|fast|prewalk|token|tool|step\s*\d+)\b/gi;
|
|
2
|
+
|
|
3
|
+
export function createInteractionPolicy() {
|
|
4
|
+
let progressShown = false;
|
|
5
|
+
let detailEnabled = false;
|
|
6
|
+
|
|
7
|
+
function present(kind, message, { detail = false } = {}) {
|
|
8
|
+
if (kind === "progress") {
|
|
9
|
+
if (progressShown) return undefined;
|
|
10
|
+
progressShown = true;
|
|
11
|
+
return "正在处理,稍后给你结果。";
|
|
12
|
+
}
|
|
13
|
+
if (kind === "advanced-control" && !detailEnabled && !detail) return undefined;
|
|
14
|
+
if (detail || detailEnabled) return message;
|
|
15
|
+
return message.replace(INTERNAL_TERMS, "内部设置");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function presentAssistantMessage(message) {
|
|
19
|
+
if (detailEnabled) return message;
|
|
20
|
+
const content = message.content
|
|
21
|
+
.filter((part) => part.type === "text")
|
|
22
|
+
.map((part) => ({ ...part, text: part.text.replace(INTERNAL_TERMS, "内部设置") }));
|
|
23
|
+
return { ...message, content };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
present,
|
|
28
|
+
presentAssistantMessage,
|
|
29
|
+
setDetailEnabled(enabled) {
|
|
30
|
+
detailEnabled = enabled;
|
|
31
|
+
},
|
|
32
|
+
isDetailEnabled() {
|
|
33
|
+
return detailEnabled;
|
|
34
|
+
},
|
|
35
|
+
resetProgress() {
|
|
36
|
+
progressShown = false;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function parseConversationControl(input) {
|
|
42
|
+
const value = input.trim();
|
|
43
|
+
if (/^(展开细节|查看细节|显示细节)$/.test(value)) return "detail";
|
|
44
|
+
if (/^(少问一点|直接做)$/.test(value)) return "proceed";
|
|
45
|
+
if (/^(关键动作先问我|先问我)$/.test(value)) return "confirm";
|
|
46
|
+
if (/^(取消|不要|拒绝)$/.test(value)) return "reject";
|
|
47
|
+
if (/^(确认|继续|同意|可以)$/.test(value)) return "accept";
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function formatDecision({ impact, recommendation, alternative, onReject }) {
|
|
52
|
+
return `需要你决定\n影响:${impact}\n建议:${recommendation}\n其他选择:${alternative}\n如果拒绝:${onReject}`;
|
|
53
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
const DEFAULT_PREFERENCES = Object.freeze({
|
|
2
|
+
autonomy: "balanced",
|
|
3
|
+
delivery: "normal",
|
|
4
|
+
});
|
|
5
|
+
|
|
6
|
+
const CONTROL_PATTERNS = [
|
|
7
|
+
[/关键动作先问我|先问我/, { autonomy: "confirm-key-actions" }],
|
|
8
|
+
[/少问一点/, { autonomy: "fewer-questions" }],
|
|
9
|
+
[/直接做/, { autonomy: "direct" }],
|
|
10
|
+
[/先给三个方向/, { delivery: "three-directions" }],
|
|
11
|
+
[/展开细节|查看细节|显示细节/, {}],
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
const FALLBACKS = Object.freeze({
|
|
15
|
+
research: {
|
|
16
|
+
missingInput: "需要可访问链接、正文、关键词或目标来源。",
|
|
17
|
+
fallback: "可先基于你提供的摘要做初步判断,或请你补充正文、截图、链接。",
|
|
18
|
+
},
|
|
19
|
+
"bug-fix": {
|
|
20
|
+
missingInput: "需要复现步骤、报错信息、相关输入或运行环境。",
|
|
21
|
+
fallback: "可先根据现象列排查清单,等你补充日志后再定位。",
|
|
22
|
+
},
|
|
23
|
+
"project-recovery": {
|
|
24
|
+
missingInput: "需要当前项目路径、上次进度、任务状态或错误现场。",
|
|
25
|
+
fallback: "可先读取本地项目状态并汇总可恢复线索。",
|
|
26
|
+
},
|
|
27
|
+
general: {
|
|
28
|
+
missingInput: "需要更明确的目标、输入材料或期望输出。",
|
|
29
|
+
fallback: "可先给出可选方向或最小可执行下一步。",
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
function classify(goal) {
|
|
34
|
+
if (/https?:\/\/|链接|帖子|查一下|调研|研究/.test(goal)) return "research";
|
|
35
|
+
if (/三个方向|创意|设计|文案|写作|起个名字/.test(goal)) return "creative";
|
|
36
|
+
if (/报错|bug|缺陷|无法复现|修复/.test(goal)) return "bug-fix";
|
|
37
|
+
if (/新功能|实现|开发|增加.*功能|添加.*功能/.test(goal)) return "feature";
|
|
38
|
+
if (/继续.*项目|恢复.*项目|上次.*停/.test(goal)) return "project-recovery";
|
|
39
|
+
return "general";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function instructionsFor(kind, preferences) {
|
|
43
|
+
const collaboration = [
|
|
44
|
+
preferences.autonomy === "direct" ? "在安全且可逆的范围内直接推进,不要先要求用户选择内部模式。" : undefined,
|
|
45
|
+
preferences.autonomy === "fewer-questions" ? "仅在缺少会明显改变结果的关键信息时提一个问题。" : undefined,
|
|
46
|
+
preferences.autonomy === "confirm-key-actions" ? "关键动作前说明影响并请求确认。" : undefined,
|
|
47
|
+
preferences.delivery === "three-directions" ? "先给出三个可区分的方向,再建议一个推荐方向。" : undefined,
|
|
48
|
+
].filter(Boolean);
|
|
49
|
+
const task = {
|
|
50
|
+
research: "优先说明来源是否可访问;无法取得内容时说明缺失并建议用户提供正文或替代来源。",
|
|
51
|
+
creative: "先给出可见的创作骨架或方向,避免暴露内部能力名称。",
|
|
52
|
+
"bug-fix": "先以可复现证据定位;无法复现时说明缺少的环境、输入或日志。",
|
|
53
|
+
feature: "先确认目标与范围;涉及高影响动作时保持既有确认边界。",
|
|
54
|
+
"project-recovery": "只在当前会话可见信息足够时恢复上下文;否则说明需要的项目状态。",
|
|
55
|
+
general: "直接用自然语言处理目标;资料不足时说明未完成部分和可行替代路径。",
|
|
56
|
+
}[kind];
|
|
57
|
+
return [...collaboration, task].join("\n");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function classifyRequest(prompt, preferences = DEFAULT_PREFERENCES) {
|
|
61
|
+
const kind = classify(prompt.trim());
|
|
62
|
+
return {
|
|
63
|
+
fallback: FALLBACKS[kind]?.fallback,
|
|
64
|
+
instructions: instructionsFor(kind, preferences),
|
|
65
|
+
kind,
|
|
66
|
+
missingInput: FALLBACKS[kind]?.missingInput,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function parseSessionPreference(input) {
|
|
71
|
+
const preferences = {};
|
|
72
|
+
const details = /展开细节|查看细节|显示细节/.test(input);
|
|
73
|
+
let goal = input;
|
|
74
|
+
for (const [pattern, changes] of CONTROL_PATTERNS) {
|
|
75
|
+
if (pattern.test(goal)) Object.assign(preferences, changes);
|
|
76
|
+
goal = goal.replace(pattern, "");
|
|
77
|
+
}
|
|
78
|
+
return { details, goal: goal.replace(/[,,。;;]+/g, " ").trim(), preferences };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const parseSessionPreferences = parseSessionPreference;
|
|
82
|
+
|
|
83
|
+
export function createRoutingPolicy() {
|
|
84
|
+
let preferences = { ...DEFAULT_PREFERENCES };
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
route(input) {
|
|
88
|
+
const parsed = parseSessionPreference(input);
|
|
89
|
+
preferences = { ...preferences, ...parsed.preferences };
|
|
90
|
+
const route = classifyRequest(parsed.goal, preferences);
|
|
91
|
+
return {
|
|
92
|
+
...route,
|
|
93
|
+
details: parsed.details,
|
|
94
|
+
goal: parsed.goal,
|
|
95
|
+
preferences: { ...preferences },
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
reset() {
|
|
99
|
+
preferences = { ...DEFAULT_PREFERENCES };
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|