@shinnodua/agent-workflows 0.0.0-stage → 0.2.6
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/.agents/agents/backend-developer/agent.md +39 -0
- package/.agents/agents/frontend-developer/agent.md +42 -0
- package/.agents/agents/project-manager/agent.md +37 -0
- package/.agents/agents/tech-lead/agent.md +41 -0
- package/.agents/agents/ui-ux-designer/agent.md +41 -0
- package/.agents/skills/add-project/SKILL.md +90 -0
- package/.agents/skills/add-project/agents/openai.yaml +4 -0
- package/.agents/skills/add-project/references/save-protocol.md +90 -0
- package/.agents/skills/approve-plan/SKILL.md +86 -0
- package/.agents/skills/approve-plan/agents/openai.yaml +4 -0
- package/.agents/skills/approve-prd/SKILL.md +59 -0
- package/.agents/skills/approve-prd/agents/openai.yaml +4 -0
- package/.agents/skills/auto-mode/SKILL.md +103 -0
- package/.agents/skills/auto-mode/agents/openai.yaml +4 -0
- package/.agents/skills/create-design/SKILL.md +197 -0
- package/.agents/skills/create-design/agents/openai.yaml +4 -0
- package/.agents/skills/create-diagram/SKILL.md +83 -0
- package/.agents/skills/create-diagram/agents/openai.yaml +4 -0
- package/.agents/skills/create-plan/SKILL.md +104 -0
- package/.agents/skills/create-plan/agents/openai.yaml +4 -0
- package/.agents/skills/create-prd/SKILL.md +82 -0
- package/.agents/skills/create-prd/agents/openai.yaml +4 -0
- package/.agents/skills/griling-plan/SKILL.md +114 -0
- package/.agents/skills/griling-plan/agents/openai.yaml +4 -0
- package/.agents/skills/griling-prd/SKILL.md +91 -0
- package/.agents/skills/griling-prd/agents/openai.yaml +4 -0
- package/.agents/skills/package-installation/SKILL.md +67 -0
- package/.agents/skills/package-installation/agents/openai.yaml +4 -0
- package/.agents/skills/project-setup/SKILL.md +104 -0
- package/.agents/skills/project-setup/agents/openai.yaml +3 -0
- package/.agents/skills/research/SKILL.md +61 -0
- package/.agents/skills/research/agents/openai.yaml +4 -0
- package/.agents/skills/sprint-meeting/SKILL.md +230 -0
- package/.agents/skills/sprint-meeting/agents/openai.yaml +4 -0
- package/.claude/agents/backend-developer.md +7 -0
- package/.claude/agents/frontend-developer.md +7 -0
- package/.claude/agents/project-manager.md +7 -0
- package/.claude/agents/tech-lead.md +7 -0
- package/.claude/agents/ui-ux-designer.md +7 -0
- package/.claude/skills/add-project/SKILL.md +10 -0
- package/.claude/skills/approve-plan/SKILL.md +8 -0
- package/.claude/skills/approve-prd/SKILL.md +8 -0
- package/.claude/skills/auto-mode/SKILL.md +8 -0
- package/.claude/skills/create-design/SKILL.md +8 -0
- package/.claude/skills/create-diagram/SKILL.md +8 -0
- package/.claude/skills/create-plan/SKILL.md +8 -0
- package/.claude/skills/create-prd/SKILL.md +8 -0
- package/.claude/skills/griling-plan/SKILL.md +8 -0
- package/.claude/skills/griling-prd/SKILL.md +8 -0
- package/.claude/skills/package-installation/SKILL.md +8 -0
- package/.claude/skills/project-setup/SKILL.md +8 -0
- package/.claude/skills/research/SKILL.md +8 -0
- package/.claude/skills/sprint-meeting/SKILL.md +8 -0
- package/.codex/prompts/add-project.md +3 -0
- package/.codex/prompts/approve-plan.md +3 -0
- package/.codex/prompts/approve-prd.md +3 -0
- package/.codex/prompts/auto-mode.md +3 -0
- package/.codex/prompts/create-design.md +3 -0
- package/.codex/prompts/create-diagram.md +3 -0
- package/.codex/prompts/create-plan.md +3 -0
- package/.codex/prompts/create-prd.md +3 -0
- package/.codex/prompts/griling-plan.md +3 -0
- package/.codex/prompts/griling-prd.md +3 -0
- package/.codex/prompts/grilling-plan.md +3 -0
- package/.codex/prompts/project-setup.md +3 -0
- package/.codex/prompts/research.md +3 -0
- package/.codex/prompts/sprint-meeting.md +3 -0
- package/.gitmodules.example +9 -0
- package/AGENTS.md +84 -0
- package/CLAUDE.md +1 -0
- package/INSTALL.md +284 -0
- package/LICENSE +21 -0
- package/README.md +342 -2
- package/bin/postinstall.js +57 -0
- package/bin/workflows.js +1172 -0
- package/bin/workflows.test.mjs +682 -0
- package/commands/add-project.md +20 -0
- package/commands/approve-plan.md +25 -0
- package/commands/approve-prd.md +24 -0
- package/commands/auto-mode.md +15 -0
- package/commands/create-design.md +20 -0
- package/commands/create-diagram.md +16 -0
- package/commands/create-plan.md +22 -0
- package/commands/create-prd.md +16 -0
- package/commands/griling-plan.md +16 -0
- package/commands/griling-prd.md +16 -0
- package/commands/grilling-plan.md +16 -0
- package/commands/project-setup.md +16 -0
- package/commands/research.md +16 -0
- package/commands/sprint-meeting.md +16 -0
- package/dashboard/.agents/skills/coding-conventions/SKILL.md +76 -0
- package/dashboard/.agents/skills/coding-conventions/agents/openai.yaml +4 -0
- package/dashboard/.agents/skills/design-system-guideline/SKILL.md +51 -0
- package/dashboard/.agents/skills/design-system-guideline/agents/openai.yaml +4 -0
- package/dashboard/.agents/skills/lint-and-fix/SKILL.md +55 -0
- package/dashboard/.agents/skills/lint-and-fix/agents/openai.yaml +4 -0
- package/dashboard/.agents/skills/taste-ui/SKILL.md +45 -0
- package/dashboard/.agents/skills/taste-ui/agents/openai.yaml +4 -0
- package/dashboard/AGENTS.md +43 -0
- package/dashboard/bun.lock +352 -0
- package/dashboard/index.html +12 -0
- package/dashboard/package.json +32 -0
- package/dashboard/src/App.tsx +5 -0
- package/dashboard/src/features/task-status/components/ActionRequiredPanel/ActionRequiredPanel.module.css +85 -0
- package/dashboard/src/features/task-status/components/ActionRequiredPanel/ActionRequiredPanel.tsx +80 -0
- package/dashboard/src/features/task-status/components/ArtifactButton/ArtifactButton.module.css +25 -0
- package/dashboard/src/features/task-status/components/ArtifactButton/ArtifactButton.tsx +29 -0
- package/dashboard/src/features/task-status/components/ArtifactSummaryCards/ArtifactSummaryCards.module.css +29 -0
- package/dashboard/src/features/task-status/components/ArtifactSummaryCards/ArtifactSummaryCards.tsx +35 -0
- package/dashboard/src/features/task-status/components/CategoryPanel/CategoryPanel.module.css +85 -0
- package/dashboard/src/features/task-status/components/CategoryPanel/CategoryPanel.tsx +150 -0
- package/dashboard/src/features/task-status/components/DashboardHeader/DashboardHeader.module.css +41 -0
- package/dashboard/src/features/task-status/components/DashboardHeader/DashboardHeader.tsx +41 -0
- package/dashboard/src/features/task-status/components/FilesPanel/FilesPanel.module.css +25 -0
- package/dashboard/src/features/task-status/components/FilesPanel/FilesPanel.tsx +40 -0
- package/dashboard/src/features/task-status/components/HardnessEngineeringPanel/HardnessEngineeringPanel.module.css +330 -0
- package/dashboard/src/features/task-status/components/HardnessEngineeringPanel/HardnessEngineeringPanel.tsx +299 -0
- package/dashboard/src/features/task-status/components/LifecyclePanel/LifecyclePanel.module.css +74 -0
- package/dashboard/src/features/task-status/components/LifecyclePanel/LifecyclePanel.tsx +79 -0
- package/dashboard/src/features/task-status/components/MarkdownDialog/MarkdownDialog.module.css +133 -0
- package/dashboard/src/features/task-status/components/MarkdownDialog/MarkdownDialog.tsx +233 -0
- package/dashboard/src/features/task-status/components/Sidebar/Sidebar.module.css +53 -0
- package/dashboard/src/features/task-status/components/Sidebar/Sidebar.tsx +163 -0
- package/dashboard/src/features/task-status/components/StatusBadge/StatusBadge.module.css +41 -0
- package/dashboard/src/features/task-status/components/StatusBadge/StatusBadge.tsx +48 -0
- package/dashboard/src/features/task-status/components/TaskOverview/TaskOverview.module.css +97 -0
- package/dashboard/src/features/task-status/components/TaskOverview/TaskOverview.tsx +128 -0
- package/dashboard/src/features/task-status/components/TaskStatusDashboard/TaskStatusDashboard.module.css +9 -0
- package/dashboard/src/features/task-status/components/TaskStatusDashboard/TaskStatusDashboard.tsx +318 -0
- package/dashboard/src/features/task-status/components/WorkflowPanel/WorkflowPanel.module.css +221 -0
- package/dashboard/src/features/task-status/components/WorkflowPanel/WorkflowPanel.tsx +344 -0
- package/dashboard/src/features/task-status/taskStatusConfig.ts +100 -0
- package/dashboard/src/features/task-status/utils/actionItems.ts +247 -0
- package/dashboard/src/features/task-status/utils/artifactGrouping.ts +328 -0
- package/dashboard/src/features/task-status/utils/hardnessScanner.ts +406 -0
- package/dashboard/src/features/task-status/utils/lifecycle.ts +73 -0
- package/dashboard/src/features/task-status/utils/markdownInline/markdownInline.module.css +11 -0
- package/dashboard/src/features/task-status/utils/markdownInline/markdownInline.tsx +104 -0
- package/dashboard/src/features/task-status/utils/markdownLinks.ts +83 -0
- package/dashboard/src/features/task-status/utils/markdownRenderer/markdownRenderer.module.css +74 -0
- package/dashboard/src/features/task-status/utils/markdownRenderer/markdownRenderer.tsx +326 -0
- package/dashboard/src/features/task-status/utils/status.ts +7 -0
- package/dashboard/src/features/task-status/utils/test/actionItems.test.ts +134 -0
- package/dashboard/src/features/task-status/utils/test/artifactGrouping.test.ts +294 -0
- package/dashboard/src/features/task-status/utils/test/hardnessScanner.test.ts +138 -0
- package/dashboard/src/features/task-status/utils/test/lifecycle.test.ts +49 -0
- package/dashboard/src/features/task-status/utils/test/markdownInline.test.ts +41 -0
- package/dashboard/src/features/task-status/utils/test/markdownLinks.test.ts +158 -0
- package/dashboard/src/features/task-status/utils/test/workspaceMetadata.test.ts +37 -0
- package/dashboard/src/features/task-status/utils/workspaceMetadata.ts +175 -0
- package/dashboard/src/main.tsx +16 -0
- package/dashboard/src/shared/design-system.css +134 -0
- package/dashboard/src/shared/design-system.tsx +84 -0
- package/dashboard/src/styles.css +41 -0
- package/dashboard/src/types.ts +133 -0
- package/dashboard/src/workspace-artifacts.d.ts +9 -0
- package/dashboard/tsconfig.json +22 -0
- package/dashboard/vite.config.ts +579 -0
- package/designs/.gitkeep +1 -0
- package/docs/add-project-command-completion.md +117 -0
- package/docs/public-npm-registry-completion.md +104 -0
- package/docs/workflows.png +0 -0
- package/docs/workspace-template-setup.md +229 -0
- package/meeting-logs/.gitkeep +1 -0
- package/modules/.gitkeep +1 -0
- package/package.json +96 -5
- package/plans/.gitkeep +1 -0
- package/prds/.gitkeep +1 -0
- package/project/PROJECT.md +26 -0
- package/project/repositories.json +72 -0
- package/project/validation.json +9 -0
- package/project/workflows.json +20 -0
- package/research/.gitkeep +1 -0
- package/roles/backend-developer.md +26 -0
- package/roles/frontend-developer.md +25 -0
- package/roles/project-manager.md +42 -0
- package/roles/tech-lead.md +42 -0
- package/roles/ui-ux-designer.md +43 -0
- package/scripts/add-project.mjs +990 -0
- package/scripts/add-project.test.mjs +804 -0
- package/scripts/check-staged-security.mjs +97 -0
- package/scripts/check-staged-security.test.mjs +68 -0
- package/scripts/workspace-integrity.ts +220 -0
- package/templates/auto-mode-completion-summary-template.md +78 -0
- package/templates/meeting-log-template.md +177 -0
- package/templates/plan-template.md +219 -0
- package/templates/prd-template.md +106 -0
- package/templates/research-template.md +119 -0
- package/workflows.md +590 -0
- package/workspace.config.json +43 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ActionItem,
|
|
3
|
+
ActionItemSeverity,
|
|
4
|
+
Artifact,
|
|
5
|
+
ProjectRepository,
|
|
6
|
+
} from "../../../types";
|
|
7
|
+
import { resolveLinkedArtifact } from "./markdownLinks";
|
|
8
|
+
import { normalizeStatus } from "./status";
|
|
9
|
+
|
|
10
|
+
export const STALE_DRAFT_DAYS = 14;
|
|
11
|
+
|
|
12
|
+
const severityRank: Record<ActionItemSeverity, number> = {
|
|
13
|
+
blocked: 0,
|
|
14
|
+
high: 1,
|
|
15
|
+
medium: 2,
|
|
16
|
+
low: 3,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function buildActionItems(
|
|
20
|
+
artifacts: Artifact[],
|
|
21
|
+
repositoriesOrNow:
|
|
22
|
+
| ProjectRepository[]
|
|
23
|
+
| Date = inferRepositoriesFromArtifacts(artifacts),
|
|
24
|
+
now = new Date(),
|
|
25
|
+
): ActionItem[] {
|
|
26
|
+
const repositories =
|
|
27
|
+
repositoriesOrNow instanceof Date
|
|
28
|
+
? inferRepositoriesFromArtifacts(artifacts)
|
|
29
|
+
: repositoriesOrNow;
|
|
30
|
+
const currentDate =
|
|
31
|
+
repositoriesOrNow instanceof Date ? repositoriesOrNow : now;
|
|
32
|
+
const items = [
|
|
33
|
+
...findMissingPlans(artifacts),
|
|
34
|
+
...findMissingSubmodulePlans(artifacts, repositories),
|
|
35
|
+
...findStaleDrafts(artifacts, currentDate),
|
|
36
|
+
...findBrokenLinks(artifacts),
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const uniqueItems = new Map<string, ActionItem>();
|
|
40
|
+
|
|
41
|
+
for (const item of items) {
|
|
42
|
+
uniqueItems.set(item.id, item);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return Array.from(uniqueItems.values()).sort((first, second) => {
|
|
46
|
+
return (
|
|
47
|
+
severityRank[first.severity] - severityRank[second.severity] ||
|
|
48
|
+
second.date.localeCompare(first.date) ||
|
|
49
|
+
first.title.localeCompare(second.title)
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function filterActionItems(items: ActionItem[], query: string) {
|
|
55
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
56
|
+
|
|
57
|
+
if (!normalizedQuery) {
|
|
58
|
+
return items;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return items.filter((item) =>
|
|
62
|
+
[
|
|
63
|
+
item.title,
|
|
64
|
+
item.reason,
|
|
65
|
+
item.severity,
|
|
66
|
+
item.artifact.relativePath,
|
|
67
|
+
item.artifact.status,
|
|
68
|
+
]
|
|
69
|
+
.join(" ")
|
|
70
|
+
.toLowerCase()
|
|
71
|
+
.includes(normalizedQuery),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function findMissingPlans(artifacts: Artifact[]) {
|
|
76
|
+
const plans = artifacts.filter((artifact) => artifact.type === "plan");
|
|
77
|
+
|
|
78
|
+
return artifacts
|
|
79
|
+
.filter(
|
|
80
|
+
(artifact) =>
|
|
81
|
+
artifact.type === "prd" &&
|
|
82
|
+
normalizeStatus(artifact.status) === "approved" &&
|
|
83
|
+
artifact.id &&
|
|
84
|
+
!plans.some(
|
|
85
|
+
(plan) =>
|
|
86
|
+
plan.prdId === artifact.id ||
|
|
87
|
+
plan.relatedArtifactIds.includes(artifact.id ?? ""),
|
|
88
|
+
),
|
|
89
|
+
)
|
|
90
|
+
.map((artifact) =>
|
|
91
|
+
createItem(
|
|
92
|
+
"missing-plan",
|
|
93
|
+
"blocked",
|
|
94
|
+
"Needs implementation plan",
|
|
95
|
+
`Approved PRD has no linked plan.`,
|
|
96
|
+
artifact,
|
|
97
|
+
),
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function findMissingSubmodulePlans(
|
|
102
|
+
artifacts: Artifact[],
|
|
103
|
+
repositories: ProjectRepository[],
|
|
104
|
+
) {
|
|
105
|
+
const rootPlans = artifacts.filter(
|
|
106
|
+
(artifact) =>
|
|
107
|
+
artifact.type === "plan" &&
|
|
108
|
+
artifact.sourceModule === "workspace" &&
|
|
109
|
+
normalizeStatus(artifact.status) === "approved",
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
return rootPlans.flatMap((plan) => {
|
|
113
|
+
const affectedModules = repositories.filter((repository) =>
|
|
114
|
+
isModuleAffected(plan.content, repository),
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
return affectedModules
|
|
118
|
+
.filter(
|
|
119
|
+
(repository) =>
|
|
120
|
+
!artifacts.some(
|
|
121
|
+
(artifact) =>
|
|
122
|
+
artifact.type === "plan" &&
|
|
123
|
+
artifact.sourceModule === repository.id &&
|
|
124
|
+
(artifact.parentPlanId === plan.id ||
|
|
125
|
+
artifact.relatedArtifactIds.includes(plan.id ?? "")),
|
|
126
|
+
),
|
|
127
|
+
)
|
|
128
|
+
.map((repository) =>
|
|
129
|
+
createItem(
|
|
130
|
+
`missing-submodule-plan-${repository.id}`,
|
|
131
|
+
"high",
|
|
132
|
+
"Missing submodule plan",
|
|
133
|
+
`Approved plan names ${repository.name} as affected but has no linked detail plan.`,
|
|
134
|
+
plan,
|
|
135
|
+
),
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function findStaleDrafts(artifacts: Artifact[], now: Date) {
|
|
141
|
+
const cutoff = now.getTime() - STALE_DRAFT_DAYS * 24 * 60 * 60 * 1000;
|
|
142
|
+
|
|
143
|
+
return artifacts
|
|
144
|
+
.filter(
|
|
145
|
+
(artifact) =>
|
|
146
|
+
artifact.type !== "document" &&
|
|
147
|
+
normalizeStatus(artifact.status) === "draft" &&
|
|
148
|
+
getArtifactDate(artifact).getTime() < cutoff,
|
|
149
|
+
)
|
|
150
|
+
.map((artifact) =>
|
|
151
|
+
createItem(
|
|
152
|
+
"stale-draft",
|
|
153
|
+
"medium",
|
|
154
|
+
"Stale draft",
|
|
155
|
+
`Draft has not been updated in ${STALE_DRAFT_DAYS} days.`,
|
|
156
|
+
artifact,
|
|
157
|
+
),
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function findBrokenLinks(artifacts: Artifact[]) {
|
|
162
|
+
return artifacts.flatMap((artifact) => {
|
|
163
|
+
const links = Array.from(
|
|
164
|
+
artifact.content.matchAll(/\[[^\]]+\]\(([^)]+\.md(?:#[^)]*)?)\)/gi),
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
return links
|
|
168
|
+
.map((match) => match[1]?.trim())
|
|
169
|
+
.filter((href): href is string => Boolean(href))
|
|
170
|
+
.filter((href) => !resolveLinkedArtifact(artifacts, artifact, href))
|
|
171
|
+
.map((href) =>
|
|
172
|
+
createItem(
|
|
173
|
+
`broken-link-${artifact.relativePath}-${href}`,
|
|
174
|
+
"high",
|
|
175
|
+
"Broken workspace link",
|
|
176
|
+
`Local Markdown target could not be found: ${href}`,
|
|
177
|
+
artifact,
|
|
178
|
+
),
|
|
179
|
+
);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function inferRepositoriesFromArtifacts(
|
|
184
|
+
artifacts: Artifact[],
|
|
185
|
+
): ProjectRepository[] {
|
|
186
|
+
const moduleIds = new Set(
|
|
187
|
+
artifacts
|
|
188
|
+
.map((artifact) => artifact.sourceModule)
|
|
189
|
+
.filter((moduleId) => moduleId !== "workspace"),
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
return Array.from(moduleIds).map((moduleId) => ({
|
|
193
|
+
id: moduleId,
|
|
194
|
+
name: moduleId,
|
|
195
|
+
path: `modules/${moduleId}`,
|
|
196
|
+
purpose: "",
|
|
197
|
+
scope: [],
|
|
198
|
+
platforms: [],
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function isModuleAffected(content: string, repository: ProjectRepository) {
|
|
203
|
+
const moduleNames = [repository.id, repository.name].filter(Boolean);
|
|
204
|
+
const moduleRow = new RegExp(
|
|
205
|
+
`\\|\\s*[^a-z0-9]*(${moduleNames.map(escapeRegExp).join("|")})[^a-z0-9]*\\|([^\\n]+)`,
|
|
206
|
+
"i",
|
|
207
|
+
).exec(content)?.[2];
|
|
208
|
+
|
|
209
|
+
if (moduleRow) {
|
|
210
|
+
return !/not affected|no product submodule|not required/i.test(moduleRow);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return [
|
|
214
|
+
repository.path,
|
|
215
|
+
`modules/${repository.id}/`,
|
|
216
|
+
`modules/${repository.name}/`,
|
|
217
|
+
]
|
|
218
|
+
.filter(Boolean)
|
|
219
|
+
.some((repositoryPath) =>
|
|
220
|
+
new RegExp(escapeRegExp(repositoryPath), "i").test(content),
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function escapeRegExp(value: string) {
|
|
225
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function createItem(
|
|
229
|
+
check: string,
|
|
230
|
+
severity: ActionItemSeverity,
|
|
231
|
+
title: string,
|
|
232
|
+
reason: string,
|
|
233
|
+
artifact: Artifact,
|
|
234
|
+
): ActionItem {
|
|
235
|
+
return {
|
|
236
|
+
artifact,
|
|
237
|
+
date: getArtifactDate(artifact).toISOString(),
|
|
238
|
+
id: `${check}-${artifact.relativePath}`,
|
|
239
|
+
reason,
|
|
240
|
+
severity,
|
|
241
|
+
title,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function getArtifactDate(artifact: Artifact) {
|
|
246
|
+
return new Date(artifact.updated ?? artifact.created ?? artifact.modified);
|
|
247
|
+
}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Artifact,
|
|
3
|
+
ArtifactType,
|
|
4
|
+
DashboardView,
|
|
5
|
+
DocumentModuleFilter,
|
|
6
|
+
DocumentModuleTab,
|
|
7
|
+
TaskGroup,
|
|
8
|
+
} from "../../../types";
|
|
9
|
+
import { artifactTypes, statusRank } from "../taskStatusConfig";
|
|
10
|
+
import { normalizeStatus } from "./status";
|
|
11
|
+
|
|
12
|
+
export function filterArtifacts(artifacts: Artifact[], query: string) {
|
|
13
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
14
|
+
|
|
15
|
+
if (!normalizedQuery) {
|
|
16
|
+
return sortArtifactsByTime(artifacts);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return sortArtifactsByTime(
|
|
20
|
+
artifacts.filter((artifact) =>
|
|
21
|
+
getArtifactSearchValues(artifact).some((value) =>
|
|
22
|
+
value.toLowerCase().includes(normalizedQuery),
|
|
23
|
+
),
|
|
24
|
+
),
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function buildTaskGroups(filteredArtifacts: Artifact[]) {
|
|
29
|
+
const groups = groupRelatedTaskArtifacts(filteredArtifacts);
|
|
30
|
+
|
|
31
|
+
return Array.from(groups.entries())
|
|
32
|
+
.map(([key, groupArtifacts]) => buildTaskGroup(key, groupArtifacts))
|
|
33
|
+
.sort(sortTaskGroups);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function countArtifactsByType(
|
|
37
|
+
artifacts: Artifact[],
|
|
38
|
+
type: ArtifactType,
|
|
39
|
+
) {
|
|
40
|
+
return artifacts.filter((artifact) => artifact.type === type).length;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getVisibleFiles(
|
|
44
|
+
filteredArtifacts: Artifact[],
|
|
45
|
+
activeView: DashboardView,
|
|
46
|
+
) {
|
|
47
|
+
if (activeView === "task") {
|
|
48
|
+
return filteredArtifacts.filter((artifact) => artifact.type !== "document");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (
|
|
52
|
+
activeView === "workflow" ||
|
|
53
|
+
activeView === "action-required" ||
|
|
54
|
+
activeView === "lifecycle"
|
|
55
|
+
) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return filteredArtifacts.filter((artifact) => artifact.type === activeView);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function filterDocumentsByModule(
|
|
63
|
+
artifacts: Artifact[],
|
|
64
|
+
moduleFilter: DocumentModuleFilter,
|
|
65
|
+
) {
|
|
66
|
+
const documents = artifacts.filter(
|
|
67
|
+
(artifact) => artifact.type === "document",
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
if (moduleFilter === "all") {
|
|
71
|
+
return documents;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return artifacts.filter(
|
|
75
|
+
(artifact) =>
|
|
76
|
+
artifact.type === "document" && artifact.sourceModule === moduleFilter,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function countDocumentsByModule(
|
|
81
|
+
artifacts: Artifact[],
|
|
82
|
+
documentModuleTabs: DocumentModuleTab[] = inferDocumentModuleTabs(artifacts),
|
|
83
|
+
) {
|
|
84
|
+
const documents = artifacts.filter(
|
|
85
|
+
(artifact) => artifact.type === "document",
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
return Object.fromEntries(
|
|
89
|
+
documentModuleTabs.map((tab) => [
|
|
90
|
+
tab.module,
|
|
91
|
+
tab.module === "all"
|
|
92
|
+
? documents.length
|
|
93
|
+
: documents.filter((artifact) => artifact.sourceModule === tab.module)
|
|
94
|
+
.length,
|
|
95
|
+
]),
|
|
96
|
+
) as Record<DocumentModuleFilter, number>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function inferDocumentModuleTabs(artifacts: Artifact[]): DocumentModuleTab[] {
|
|
100
|
+
const moduleIds = Array.from(
|
|
101
|
+
new Set(artifacts.map((artifact) => artifact.sourceModule)),
|
|
102
|
+
).sort((first, second) => first.localeCompare(second));
|
|
103
|
+
|
|
104
|
+
return [
|
|
105
|
+
{ module: "all", label: "All" },
|
|
106
|
+
...moduleIds.map((moduleId) => ({
|
|
107
|
+
module: moduleId,
|
|
108
|
+
label: moduleId === "workspace" ? "Workspace" : moduleId,
|
|
109
|
+
})),
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function getArtifactSearchValues(artifact: Artifact) {
|
|
114
|
+
return [
|
|
115
|
+
artifact.title,
|
|
116
|
+
artifact.status,
|
|
117
|
+
artifact.id,
|
|
118
|
+
artifact.prdId,
|
|
119
|
+
artifact.planId,
|
|
120
|
+
...artifact.relatedArtifactIds,
|
|
121
|
+
artifact.relativePath,
|
|
122
|
+
artifact.sourceModule,
|
|
123
|
+
artifact.taskKey,
|
|
124
|
+
].filter((value): value is string => Boolean(value));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function groupRelatedTaskArtifacts(artifacts: Artifact[]) {
|
|
128
|
+
const taskArtifacts = artifacts.filter(
|
|
129
|
+
(artifact) => artifact.type !== "document",
|
|
130
|
+
);
|
|
131
|
+
const unionFind = new UnionFind(taskArtifacts.length);
|
|
132
|
+
const indexesByTaskKey = new Map<string, number[]>();
|
|
133
|
+
const indexById = new Map<string, number>();
|
|
134
|
+
|
|
135
|
+
taskArtifacts.forEach((artifact, index) => {
|
|
136
|
+
if (artifact.taskKey) {
|
|
137
|
+
indexesByTaskKey.set(artifact.taskKey, [
|
|
138
|
+
...(indexesByTaskKey.get(artifact.taskKey) ?? []),
|
|
139
|
+
index,
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (artifact.id) {
|
|
144
|
+
indexById.set(artifact.id, index);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
for (const indexes of indexesByTaskKey.values()) {
|
|
149
|
+
unionIndexes(unionFind, indexes);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
taskArtifacts.forEach((artifact, index) => {
|
|
153
|
+
for (const relatedId of getRelatedArtifactIds(artifact)) {
|
|
154
|
+
const relatedIndex = indexById.get(relatedId);
|
|
155
|
+
|
|
156
|
+
if (relatedIndex !== undefined) {
|
|
157
|
+
unionFind.union(index, relatedIndex);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const groupsByRoot = new Map<number, Artifact[]>();
|
|
163
|
+
|
|
164
|
+
taskArtifacts.forEach((artifact, index) => {
|
|
165
|
+
const root = unionFind.find(index);
|
|
166
|
+
groupsByRoot.set(root, [...(groupsByRoot.get(root) ?? []), artifact]);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const groups = new Map<string, Artifact[]>();
|
|
170
|
+
|
|
171
|
+
for (const groupArtifacts of groupsByRoot.values()) {
|
|
172
|
+
groups.set(getTaskGroupKey(groupArtifacts), groupArtifacts);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return groups;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function unionIndexes(unionFind: UnionFind, indexes: number[]) {
|
|
179
|
+
const [firstIndex, ...remainingIndexes] = indexes;
|
|
180
|
+
|
|
181
|
+
if (firstIndex === undefined) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
for (const index of remainingIndexes) {
|
|
186
|
+
unionFind.union(firstIndex, index);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function getRelatedArtifactIds(artifact: Artifact) {
|
|
191
|
+
return [
|
|
192
|
+
artifact.prdId,
|
|
193
|
+
artifact.planId,
|
|
194
|
+
artifact.parentPlanId,
|
|
195
|
+
...artifact.relatedArtifactIds,
|
|
196
|
+
].filter((id): id is string => Boolean(id));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function getTaskGroupKey(groupArtifacts: Artifact[]) {
|
|
200
|
+
const preferred =
|
|
201
|
+
groupArtifacts.find((artifact) => artifact.type === "prd") ??
|
|
202
|
+
groupArtifacts.find((artifact) => artifact.type === "plan") ??
|
|
203
|
+
groupArtifacts.find((artifact) => artifact.type === "research") ??
|
|
204
|
+
groupArtifacts[0];
|
|
205
|
+
|
|
206
|
+
return preferred?.taskKey || "ungrouped";
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function buildTaskGroup(key: string, groupArtifacts: Artifact[]): TaskGroup {
|
|
210
|
+
return {
|
|
211
|
+
artifacts: groupArtifacts,
|
|
212
|
+
byType: buildArtifactsByType(groupArtifacts),
|
|
213
|
+
key,
|
|
214
|
+
description: getTaskDescription(groupArtifacts),
|
|
215
|
+
status: getGroupStatus(groupArtifacts),
|
|
216
|
+
title: getTaskTitle(groupArtifacts),
|
|
217
|
+
updated: getLatestArtifactDate(groupArtifacts),
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function getTaskDescription(groupArtifacts: Artifact[]) {
|
|
222
|
+
const preferred =
|
|
223
|
+
groupArtifacts.find(
|
|
224
|
+
(artifact) => artifact.type === "prd" && artifact.goal,
|
|
225
|
+
) ??
|
|
226
|
+
groupArtifacts.find(
|
|
227
|
+
(artifact) => artifact.type === "plan" && artifact.goal,
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
return preferred?.goal;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function buildArtifactsByType(groupArtifacts: Artifact[]) {
|
|
234
|
+
return Object.fromEntries(
|
|
235
|
+
artifactTypes.map((artifactType) => [
|
|
236
|
+
artifactType.type,
|
|
237
|
+
sortArtifactsByTime(
|
|
238
|
+
groupArtifacts.filter(
|
|
239
|
+
(artifact) => artifact.type === artifactType.type,
|
|
240
|
+
),
|
|
241
|
+
),
|
|
242
|
+
]),
|
|
243
|
+
) as Record<ArtifactType, Artifact[]>;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function getGroupStatus(groupArtifacts: Artifact[]) {
|
|
247
|
+
const statuses = groupArtifacts.map((artifact) =>
|
|
248
|
+
normalizeStatus(artifact.status),
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
return (
|
|
252
|
+
statusRank.find((status) => statuses.includes(status)) ??
|
|
253
|
+
statuses[0] ??
|
|
254
|
+
"unknown"
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function getTaskTitle(groupArtifacts: Artifact[]) {
|
|
259
|
+
const preferred =
|
|
260
|
+
groupArtifacts.find((artifact) => artifact.type === "prd") ??
|
|
261
|
+
groupArtifacts.find((artifact) => artifact.type === "plan") ??
|
|
262
|
+
groupArtifacts[0];
|
|
263
|
+
|
|
264
|
+
return preferred?.title ?? "Untitled task";
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function getLatestArtifactDate(groupArtifacts: Artifact[]) {
|
|
268
|
+
return groupArtifacts
|
|
269
|
+
.map(getArtifactTime)
|
|
270
|
+
.filter((date): date is string => Boolean(date))
|
|
271
|
+
.sort()
|
|
272
|
+
.at(-1);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function getArtifactTime(artifact: Artifact) {
|
|
276
|
+
return artifact.updated ?? artifact.created ?? artifact.modified;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function sortArtifactsByTime(artifacts: Artifact[]) {
|
|
280
|
+
return [...artifacts].sort((first, second) => {
|
|
281
|
+
const firstDate = getArtifactTime(first);
|
|
282
|
+
const secondDate = getArtifactTime(second);
|
|
283
|
+
|
|
284
|
+
return (
|
|
285
|
+
secondDate.localeCompare(firstDate) ||
|
|
286
|
+
first.relativePath.localeCompare(second.relativePath, "en")
|
|
287
|
+
);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function sortTaskGroups(first: TaskGroup, second: TaskGroup) {
|
|
292
|
+
const firstDate = first.updated ?? "";
|
|
293
|
+
const secondDate = second.updated ?? "";
|
|
294
|
+
|
|
295
|
+
return (
|
|
296
|
+
secondDate.localeCompare(firstDate) ||
|
|
297
|
+
first.title.localeCompare(second.title)
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
class UnionFind {
|
|
302
|
+
private readonly parents: number[];
|
|
303
|
+
|
|
304
|
+
constructor(size: number) {
|
|
305
|
+
this.parents = Array.from({ length: size }, (_value, index) => index);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
find(index: number): number {
|
|
309
|
+
const parent = this.parents[index] ?? index;
|
|
310
|
+
|
|
311
|
+
if (parent === index) {
|
|
312
|
+
return index;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const root = this.find(parent);
|
|
316
|
+
this.parents[index] = root;
|
|
317
|
+
return root;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
union(first: number, second: number) {
|
|
321
|
+
const firstRoot = this.find(first);
|
|
322
|
+
const secondRoot = this.find(second);
|
|
323
|
+
|
|
324
|
+
if (firstRoot !== secondRoot) {
|
|
325
|
+
this.parents[secondRoot] = firstRoot;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|