@ai-setting/roy-plugin-task-show 0.6.11 → 0.8.4
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/README.md +121 -1
- package/dist/cli-tasks-adapter.d.ts +142 -0
- package/dist/cli-tasks-adapter.d.ts.map +1 -0
- package/dist/cli-tasks-adapter.js +379 -0
- package/dist/cli-tasks-adapter.js.map +1 -0
- package/dist/cli-tasks-tree-adapter.d.ts +143 -0
- package/dist/cli-tasks-tree-adapter.d.ts.map +1 -0
- package/dist/cli-tasks-tree-adapter.js +400 -0
- package/dist/cli-tasks-tree-adapter.js.map +1 -0
- package/dist/operations-cache.d.ts +44 -0
- package/dist/operations-cache.d.ts.map +1 -0
- package/dist/operations-cache.js +103 -0
- package/dist/operations-cache.js.map +1 -0
- package/dist/plugin.d.ts +14 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +82 -0
- package/dist/plugin.js.map +1 -1
- package/dist/server.d.ts +30 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +289 -89
- package/dist/server.js.map +1 -1
- package/dist/task-detail-mermaid.d.ts +171 -0
- package/dist/task-detail-mermaid.d.ts.map +1 -0
- package/dist/task-detail-mermaid.js +697 -0
- package/dist/task-detail-mermaid.js.map +1 -0
- package/dist/task-operations-html.d.ts +50 -0
- package/dist/task-operations-html.d.ts.map +1 -0
- package/dist/task-operations-html.js +187 -0
- package/dist/task-operations-html.js.map +1 -0
- package/dist/tasks-tree-cache.d.ts +44 -0
- package/dist/tasks-tree-cache.d.ts.map +1 -0
- package/dist/tasks-tree-cache.js +111 -0
- package/dist/tasks-tree-cache.js.map +1 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +6 -1
- package/plugin.json +2 -2
- package/public/app.js +534 -34
- package/public/index.html +54 -21
- package/public/style.css +697 -1
- package/public/task-operations.js +290 -0
- package/public/tasks-tree.js +449 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Mermaid "task lifecycle + tool calls" diagram generator.
|
|
3
|
+
*
|
|
4
|
+
* v0.8.0: replaces the per-task page's old "Execution flow (Mermaid)"
|
|
5
|
+
* section (which only listed tool calls in a flat sequence) with a
|
|
6
|
+
* two-level view that nests each tool call under the operation record
|
|
7
|
+
* that produced it. The structure is:
|
|
8
|
+
*
|
|
9
|
+
* Start([Task #X start]) --> opN subgraph --> End([Task #X end])
|
|
10
|
+
* │
|
|
11
|
+
* ├── tool_1["🔧 edit_file / adapter.ts"]
|
|
12
|
+
* └── tool_2["🔧 bash / ls -la"]
|
|
13
|
+
*
|
|
14
|
+
* Each tool node has a `click tool_1 callback` directive so the browser
|
|
15
|
+
* navigates to the tool table row when the user clicks the node. The
|
|
16
|
+
* callback is `window.__toolClick(toolId)` — see `public/app.js` and
|
|
17
|
+
* `public/mermaid-renderer.js` for the implementation.
|
|
18
|
+
*
|
|
19
|
+
* v0.8.2 (fix/mermaid-readable-labels): replaces the raw
|
|
20
|
+
* `<seq>. <title>` operation-subgraph labels (which leaked technical
|
|
21
|
+
* details such as `plan_doc: docs/.../plan.md - 485 - worktree: HEAD
|
|
22
|
+
* a487b25f from main`) with a concise, human-readable label derived
|
|
23
|
+
* from a `PHASE_LABELS` metadata map. The map is keyed by a canonical
|
|
24
|
+
* phase id (`init-task`, `setup-worktree`, `plan`, `tdd-implement`,
|
|
25
|
+
* `code-review`, `cli-e2e-test`, `final-verify`, `merge-to-main`,
|
|
26
|
+
* `summary-report`, `task-complete`) and each entry has an emoji, a
|
|
27
|
+
* friendly name, and a short description. `getPhaseLabel(op)` parses
|
|
28
|
+
* the operation title for a `Phase N: <name>` pattern, looks up the
|
|
29
|
+
* matching phaseId via `PHASE_ALIASES`, and returns
|
|
30
|
+
* `<emoji> Phase N: <friendly-name><br/><description>`. Unknown
|
|
31
|
+
* titles fall back to a sanitized version (technical fields stripped
|
|
32
|
+
* at the first ` - <field>:` marker). The same logic is mirrored in
|
|
33
|
+
* `public/app.js` so the client-side re-render stays in sync.
|
|
34
|
+
*
|
|
35
|
+
* This module is a pure function. No DOM access. No I/O. Easy to unit
|
|
36
|
+
* test and to compose with other renderers.
|
|
37
|
+
*/
|
|
38
|
+
import type { OperationRecord } from "./cli-tasks-adapter.js";
|
|
39
|
+
import type { ToolCallRecord } from "./types.js";
|
|
40
|
+
/**
|
|
41
|
+
* Canonical phase metadata. Each phase is a node in the workflow
|
|
42
|
+
* (tongagent-rd-pipeline in our reference deployment). The `name`
|
|
43
|
+
* field is what the user sees in the Mermaid label; the `description`
|
|
44
|
+
* is a one-line tooltip-like context. We keep this list small and
|
|
45
|
+
* frozen — adding a phase means a deliberate change to the workflow.
|
|
46
|
+
*/
|
|
47
|
+
export interface PhaseMeta {
|
|
48
|
+
emoji: string;
|
|
49
|
+
name: string;
|
|
50
|
+
description: string;
|
|
51
|
+
}
|
|
52
|
+
export declare const PHASE_LABELS: Record<string, PhaseMeta>;
|
|
53
|
+
/**
|
|
54
|
+
* Aliases that map the various spellings the workflow uses in
|
|
55
|
+
* `milestoneTitle` to a canonical phaseId. The lookup is performed
|
|
56
|
+
* case-insensitively, with whitespace + punctuation normalised, so
|
|
57
|
+
* "Plan" / "plan" / "(Plan)" / "Plan — ..." all resolve the same way.
|
|
58
|
+
* Extend this map (rather than special-casing in `getPhaseLabel`) when
|
|
59
|
+
* the workflow grows new phase aliases.
|
|
60
|
+
*/
|
|
61
|
+
export declare const PHASE_ALIASES: Record<string, string>;
|
|
62
|
+
/**
|
|
63
|
+
* Try to extract "Phase N" + name from an operation title. Returns
|
|
64
|
+
* `null` if no `Phase N` token is present. Exported for tests so the
|
|
65
|
+
* parser is independently testable.
|
|
66
|
+
*
|
|
67
|
+
* Recognised shapes:
|
|
68
|
+
* "Phase 3: Plan - plan_doc: ..."
|
|
69
|
+
* "Phase 3 (Plan) 完成 — ..."
|
|
70
|
+
* "Phase 3 Plan 完整循环 ..."
|
|
71
|
+
* "Phase 3. Plan: ..."
|
|
72
|
+
* "phase 5 code-review: PASS" (lowercase ok)
|
|
73
|
+
* "Task #X 创建成功(Phase 1 任务管理完成)" (Phase N anywhere in the title)
|
|
74
|
+
*
|
|
75
|
+
* The name is captured up to the first stop-token (`-`, `—`, `:`,
|
|
76
|
+
* `,`, `。`, `完成`, `pass`, newline), so trailing technical details
|
|
77
|
+
* like `plan_doc:` or `worktree: HEAD ...` don't leak in. Hyphens
|
|
78
|
+
* inside the name (e.g. `setup-worktree`, `code-review`) are
|
|
79
|
+
* preserved.
|
|
80
|
+
*/
|
|
81
|
+
export declare function extractPhaseInfo(title: string): {
|
|
82
|
+
num: string;
|
|
83
|
+
name: string;
|
|
84
|
+
} | null;
|
|
85
|
+
/**
|
|
86
|
+
* Map a raw phase name to a canonical phaseId via `PHASE_ALIASES`.
|
|
87
|
+
* Returns `null` if no alias matches.
|
|
88
|
+
*/
|
|
89
|
+
export declare function resolvePhaseId(phaseName: string): string | null;
|
|
90
|
+
export declare function sanitiseTitleForLabel(title: string): string;
|
|
91
|
+
/**
|
|
92
|
+
* Build a human-readable Mermaid label for a single operation
|
|
93
|
+
* record. The output is a single line (with `<br/>` for visual
|
|
94
|
+
* line-break in the Mermaid render) and contains no Mermaid-hostile
|
|
95
|
+
* characters. Examples:
|
|
96
|
+
*
|
|
97
|
+
* getPhaseLabel({ title: "Phase 3: Plan - plan_doc: ... - worktree: HEAD ..." })
|
|
98
|
+
* -> "📝 Phase 3: Plan<br/>brainstorming + writing-plans"
|
|
99
|
+
*
|
|
100
|
+
* getPhaseLabel({ title: "Phase 5 code-review: PASS" })
|
|
101
|
+
* -> "🔍 Phase 5: Code Review<br/>BLOCKING/IMPORTANT/MINOR/NIT"
|
|
102
|
+
*
|
|
103
|
+
* getPhaseLabel({ title: "TDD 完整循环结束" })
|
|
104
|
+
* -> "🧪 TDD 循环<br/>RED → GREEN → REFACTOR"
|
|
105
|
+
*
|
|
106
|
+
* getPhaseLabel({ title: "RED: 3 failing tests added" })
|
|
107
|
+
* -> "⚙️ RED: 3 failing tests added" (fallback, no Phase prefix)
|
|
108
|
+
*
|
|
109
|
+
* getPhaseLabel({ title: "" })
|
|
110
|
+
* -> "⚙️ op" (milestoneType fallback)
|
|
111
|
+
*/
|
|
112
|
+
export declare function getPhaseLabel(op: Pick<OperationRecord, "title" | "milestoneType">): string;
|
|
113
|
+
/** Minimal shape we need from a tool call. Re-export for convenience. */
|
|
114
|
+
export type { ToolCallRecord };
|
|
115
|
+
/** What the Mermaid node identifier looks like for a given tool call. */
|
|
116
|
+
export declare function toolNodeId(sequence: number): string;
|
|
117
|
+
/** Mermaid node identifier for an operation record (by sequence). */
|
|
118
|
+
export declare function opNodeId(sequence: number): string;
|
|
119
|
+
/** Mermaid node identifier for the "pre-task" / "post-task" bookends. */
|
|
120
|
+
export declare const PRE_TASK_NODE = "pre_task";
|
|
121
|
+
export declare const POST_TASK_NODE = "post_task";
|
|
122
|
+
export declare const START_NODE = "task_start";
|
|
123
|
+
export declare const END_NODE = "task_end";
|
|
124
|
+
/** Options controlling the diagram. */
|
|
125
|
+
export interface BuildTaskLifecycleDiagramOpts {
|
|
126
|
+
/** Task id — used only in the start/end labels. */
|
|
127
|
+
taskId: number;
|
|
128
|
+
/** Operations in ascending sequence order (sorted by `timestamp`). */
|
|
129
|
+
operations: OperationRecord[];
|
|
130
|
+
/** Tool calls in ascending sequence order (sorted by `timestamp`). */
|
|
131
|
+
toolCalls: ToolCallRecord[];
|
|
132
|
+
/**
|
|
133
|
+
* If true, the diagram will be returned as a fully-rendered Mermaid
|
|
134
|
+
* `flowchart TD` block. If false, returns just the body (no header).
|
|
135
|
+
* Defaults to true.
|
|
136
|
+
*/
|
|
137
|
+
withHeader?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Optional label suffix for the end node (e.g. "✅ completed" or
|
|
140
|
+
* "❌ failed"). Defaults to "end".
|
|
141
|
+
*/
|
|
142
|
+
endLabel?: string;
|
|
143
|
+
}
|
|
144
|
+
/** Outcome of a single tool-call → operation assignment (mostly for tests). */
|
|
145
|
+
export interface ToolAssignment {
|
|
146
|
+
toolSequence: number;
|
|
147
|
+
opSequence: number | null;
|
|
148
|
+
bucket: "pre-task" | "post-task" | "in-op";
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Decide which operation (if any) "owns" a given tool call. The
|
|
152
|
+
* heuristic: a tool with timestamp T belongs to opN if
|
|
153
|
+
* opN.timestamp <= T < opN+1.timestamp
|
|
154
|
+
* (sorted ascending by timestamp). Tools before the first op go to
|
|
155
|
+
* "pre-task", tools after the last op go to "post-task".
|
|
156
|
+
*
|
|
157
|
+
* Exported so tests can verify the bucketing independently of the
|
|
158
|
+
* Mermaid rendering.
|
|
159
|
+
*/
|
|
160
|
+
export declare function assignToolsToOps(operations: OperationRecord[], toolCalls: ToolCallRecord[]): ToolAssignment[];
|
|
161
|
+
/**
|
|
162
|
+
* Pick the most descriptive path label from a tool's args. We try a
|
|
163
|
+
* bunch of canonical field names; if none matches, return the empty
|
|
164
|
+
* string (the caller will decide whether to show just the tool name).
|
|
165
|
+
*/
|
|
166
|
+
export declare function pickPathLabel(args: Record<string, unknown> | undefined): string;
|
|
167
|
+
/** Replace Mermaid-unfriendly characters in a label with safe equivalents. */
|
|
168
|
+
export declare function escapeMermaidLabel(s: string): string;
|
|
169
|
+
/** Build the diagram source. */
|
|
170
|
+
export declare function buildTaskLifecycleDiagram(opts: BuildTaskLifecycleDiagramOpts): string;
|
|
171
|
+
//# sourceMappingURL=task-detail-mermaid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-detail-mermaid.d.ts","sourceRoot":"","sources":["../src/task-detail-mermaid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,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