pi-ate-workflow 0.2.0 → 0.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-ate-workflow",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "type": "commonjs",
5
5
  "main": "index.ts",
6
6
  "description": "Workflow orchestration extension for pi-coding-agent — subagent spawning, research workflow, output capture",
@@ -1,15 +1,17 @@
1
1
  import { describe, it, expect } from "vitest";
2
2
  import * as fs from "node:fs";
3
3
  import * as path from "node:path";
4
+ import * as api from "../index";
4
5
 
5
6
  // ============================================================
6
- // Smoke Test: barrel export + package.json 检查
7
+ // Smoke Test: 包契约检查
8
+ // 断言稳定契约(运行时导出可用、关键字段),不匹配内部源码文本,
9
+ // 避免改名/重构后断言过期长期红(2026-09-04 事故教训)。
7
10
  // ============================================================
8
11
 
9
- describe("smoke: barrel export", () => {
10
- it("所有公共 API 从 index.ts barrel export 成功", () => {
11
- // 验证 barrel export 的 API 名称列表与 plan 一致
12
- const exports = [
12
+ describe("smoke: 运行时导出", () => {
13
+ it("所有公共 API 函数可从 index.ts 导入", () => {
14
+ const functions = [
13
15
  "runSubagent",
14
16
  "loadAgentDef",
15
17
  "createSubagentWidget",
@@ -19,108 +21,33 @@ describe("smoke: barrel export", () => {
19
21
  "createUIUpdater",
20
22
  "registerWorkflowTool",
21
23
  ];
22
- const expectedTypeExports = [
23
- "AgentDef",
24
- "SubagentResult",
25
- "SubagentEvent",
26
- "ActionDef",
27
- ];
28
-
29
- // 验证函数名列表完整
30
- expect(exports).toHaveLength(8);
31
- expect(expectedTypeExports).toHaveLength(4);
32
-
33
- // 全部函数名存在且无重复
34
- const allNames = [...exports, ...expectedTypeExports];
35
- const uniqueNames = new Set(allNames);
36
- expect(uniqueNames.size).toBe(allNames.length);
37
-
38
- // 验证 index.ts 中每个函数都有对应的子模块文件
39
- const workflowDir = path.resolve(__dirname, "..");
40
- const files = [
41
- "subagent.ts",
42
- "subagent-utils.ts",
43
- "widget.ts",
44
- "output.ts",
45
- "types.ts",
46
- "state.ts",
47
- "workflow.ts",
48
- "index.ts",
49
- ];
50
- for (const file of files) {
51
- const filePath = path.join(workflowDir, file);
52
- expect(fs.existsSync(filePath)).toBe(true);
24
+ for (const name of functions) {
25
+ expect(api, `缺少导出: ${name}`).toHaveProperty(name);
26
+ expect((api as Record<string, unknown>)[name], `${name} 应为函数`).toBeTypeOf("function");
53
27
  }
54
28
  });
29
+ });
55
30
 
56
- it("index.ts 包含所有 barrel export 语句", () => {
57
- const indexPath = path.resolve(__dirname, "..", "index.ts");
58
- const content = fs.readFileSync(indexPath, "utf-8");
59
-
60
- // 验证导出语句
61
- expect(content).toContain('export { runSubagent } from "./subagent"');
62
- expect(content).toContain('export { type AgentDef, loadAgentDef } from "@pi-atelier/shared-utils"');
63
- expect(content).toContain('export { createSubagentWidget } from "./widget"');
64
- expect(content).toContain('export { saveSubagentOutput, readSubagentOutput } from "./output"');
65
- expect(content).toContain('export type { SubagentResult, SubagentEvent } from "./types"');
66
- expect(content).toContain('export { createStateManager, createUIUpdater } from "./state"');
67
- expect(content).toContain('export { registerWorkflowTool, type ActionDef } from "./workflow"');
68
- });
69
-
70
- it("package.json 字段完整", () => {
71
- const pkgPath = path.resolve(__dirname, "..", "package.json");
72
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
31
+ describe("smoke: package.json 稳定字段", () => {
32
+ const pkgPath = path.resolve(__dirname, "..", "package.json");
33
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
73
34
 
74
- expect(pkg.name).toBe("workflow");
75
- expect(pkg.version).toBe("1.0.0");
76
- expect(pkg.type).toBe("commonjs");
35
+ it("包名与入口符合发布契约", () => {
36
+ expect(pkg.name).toBe("pi-ate-workflow");
77
37
  expect(pkg.main).toBe("index.ts");
78
-
79
- // dependencies 为空
80
- expect(pkg.dependencies).toEqual({});
81
-
82
- // peerDependencies 包含 pi-core 依赖
83
- expect(pkg.peerDependencies?.["@earendil-works/pi-coding-agent"]).toBe("*");
84
- expect(pkg.peerDependencies?.["@earendil-works/pi-tui"]).toBe("*");
85
- expect(pkg.peerDependencies?.["typebox"]).toBe("*");
86
-
87
- // devDependencies
88
- expect(pkg.devDependencies?.["vitest"]).toBeDefined();
89
- expect(pkg.devDependencies?.["@types/node"]).toBeDefined();
90
- });
91
-
92
- it("vitest.config.ts 存在且格式正确", () => {
93
- const configPath = path.resolve(__dirname, "..", "vitest.config.ts");
94
- const content = fs.readFileSync(configPath, "utf-8");
95
-
96
- expect(content).toContain("defineConfig");
97
- expect(content).toContain("tests/**/*.test.ts");
38
+ expect(pkg.type).toBe("commonjs");
98
39
  });
99
40
 
100
- it("所有 .ts 文件行数不超过 200 行", () => {
101
- const workflowDir = path.resolve(__dirname, "..");
102
- const tsFiles = fs.readdirSync(workflowDir).filter(f => f.endsWith(".ts") && f !== "vitest.config.ts");
103
-
104
- for (const file of tsFiles) {
105
- const lines = fs.readFileSync(path.join(workflowDir, file), "utf-8").split("\n").length;
106
- expect(
107
- lines,
108
- `${file} 行数 ${lines} 超过 200 行`,
109
- ).toBeLessThanOrEqual(200);
110
- }
41
+ it("peerDependencies 含 pi SDK", () => {
42
+ expect(pkg.peerDependencies?.["@earendil-works/pi-coding-agent"]).toBeDefined();
111
43
  });
44
+ });
112
45
 
113
- it("types.ts 只导出 SubagentResult + SubagentEvent,不含 PV 专用类型", () => {
46
+ describe("smoke: types.ts 不含 PV 专用类型", () => {
47
+ it("types.ts 保持通用", () => {
114
48
  const typesPath = path.resolve(__dirname, "..", "types.ts");
115
49
  const content = fs.readFileSync(typesPath, "utf-8");
116
50
 
117
- // types.ts 不应包含 PV 专用类型
118
51
  expect(content).not.toContain("PlanVerifyState");
119
- expect(content).not.toContain("Phase");
120
- expect(content).not.toContain("Issue");
121
-
122
- // 应包含通用类型
123
- expect(content).toContain("SubagentResult");
124
- expect(content).toContain("SubagentEvent");
125
52
  });
126
53
  });
package/vitest.config.ts CHANGED
@@ -2,7 +2,6 @@ import { createConfig } from "../vitest.config.base";
2
2
 
3
3
  export default createConfig({
4
4
  include: ["tests/**/*.test.ts"],
5
- exclude: ["**/*.subagent.test.ts"],
6
5
  test: {
7
6
  coverage: {
8
7
  exclude: [