@shinnodua/agent-workflows 0.0.0-stage → 0.2.8

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.
Files changed (190) hide show
  1. package/.agents/agents/backend-developer/agent.md +39 -0
  2. package/.agents/agents/frontend-developer/agent.md +42 -0
  3. package/.agents/agents/project-manager/agent.md +37 -0
  4. package/.agents/agents/tech-lead/agent.md +41 -0
  5. package/.agents/agents/ui-ux-designer/agent.md +41 -0
  6. package/.agents/skills/add-project/SKILL.md +90 -0
  7. package/.agents/skills/add-project/agents/openai.yaml +4 -0
  8. package/.agents/skills/add-project/references/save-protocol.md +90 -0
  9. package/.agents/skills/approve-plan/SKILL.md +86 -0
  10. package/.agents/skills/approve-plan/agents/openai.yaml +4 -0
  11. package/.agents/skills/approve-prd/SKILL.md +59 -0
  12. package/.agents/skills/approve-prd/agents/openai.yaml +4 -0
  13. package/.agents/skills/auto-mode/SKILL.md +103 -0
  14. package/.agents/skills/auto-mode/agents/openai.yaml +4 -0
  15. package/.agents/skills/create-design/SKILL.md +197 -0
  16. package/.agents/skills/create-design/agents/openai.yaml +4 -0
  17. package/.agents/skills/create-diagram/SKILL.md +83 -0
  18. package/.agents/skills/create-diagram/agents/openai.yaml +4 -0
  19. package/.agents/skills/create-plan/SKILL.md +104 -0
  20. package/.agents/skills/create-plan/agents/openai.yaml +4 -0
  21. package/.agents/skills/create-prd/SKILL.md +82 -0
  22. package/.agents/skills/create-prd/agents/openai.yaml +4 -0
  23. package/.agents/skills/griling-plan/SKILL.md +114 -0
  24. package/.agents/skills/griling-plan/agents/openai.yaml +4 -0
  25. package/.agents/skills/griling-prd/SKILL.md +91 -0
  26. package/.agents/skills/griling-prd/agents/openai.yaml +4 -0
  27. package/.agents/skills/package-installation/SKILL.md +67 -0
  28. package/.agents/skills/package-installation/agents/openai.yaml +4 -0
  29. package/.agents/skills/project-setup/SKILL.md +104 -0
  30. package/.agents/skills/project-setup/agents/openai.yaml +3 -0
  31. package/.agents/skills/research/SKILL.md +61 -0
  32. package/.agents/skills/research/agents/openai.yaml +4 -0
  33. package/.agents/skills/sprint-meeting/SKILL.md +230 -0
  34. package/.agents/skills/sprint-meeting/agents/openai.yaml +4 -0
  35. package/.claude/agents/backend-developer.md +7 -0
  36. package/.claude/agents/frontend-developer.md +7 -0
  37. package/.claude/agents/project-manager.md +7 -0
  38. package/.claude/agents/tech-lead.md +7 -0
  39. package/.claude/agents/ui-ux-designer.md +7 -0
  40. package/.claude/skills/add-project/SKILL.md +10 -0
  41. package/.claude/skills/approve-plan/SKILL.md +8 -0
  42. package/.claude/skills/approve-prd/SKILL.md +8 -0
  43. package/.claude/skills/auto-mode/SKILL.md +8 -0
  44. package/.claude/skills/create-design/SKILL.md +8 -0
  45. package/.claude/skills/create-diagram/SKILL.md +8 -0
  46. package/.claude/skills/create-plan/SKILL.md +8 -0
  47. package/.claude/skills/create-prd/SKILL.md +8 -0
  48. package/.claude/skills/griling-plan/SKILL.md +8 -0
  49. package/.claude/skills/griling-prd/SKILL.md +8 -0
  50. package/.claude/skills/package-installation/SKILL.md +8 -0
  51. package/.claude/skills/project-setup/SKILL.md +8 -0
  52. package/.claude/skills/research/SKILL.md +8 -0
  53. package/.claude/skills/sprint-meeting/SKILL.md +8 -0
  54. package/.codex/prompts/add-project.md +3 -0
  55. package/.codex/prompts/approve-plan.md +3 -0
  56. package/.codex/prompts/approve-prd.md +3 -0
  57. package/.codex/prompts/auto-mode.md +3 -0
  58. package/.codex/prompts/create-design.md +3 -0
  59. package/.codex/prompts/create-diagram.md +3 -0
  60. package/.codex/prompts/create-plan.md +3 -0
  61. package/.codex/prompts/create-prd.md +3 -0
  62. package/.codex/prompts/griling-plan.md +3 -0
  63. package/.codex/prompts/griling-prd.md +3 -0
  64. package/.codex/prompts/grilling-plan.md +3 -0
  65. package/.codex/prompts/project-setup.md +3 -0
  66. package/.codex/prompts/research.md +3 -0
  67. package/.codex/prompts/sprint-meeting.md +3 -0
  68. package/.gitmodules.example +9 -0
  69. package/AGENTS.md +84 -0
  70. package/CLAUDE.md +1 -0
  71. package/INSTALL.md +284 -0
  72. package/LICENSE +21 -0
  73. package/README.md +342 -2
  74. package/bin/postinstall.js +57 -0
  75. package/bin/workflows.js +1172 -0
  76. package/bin/workflows.test.mjs +682 -0
  77. package/commands/add-project.md +20 -0
  78. package/commands/approve-plan.md +25 -0
  79. package/commands/approve-prd.md +24 -0
  80. package/commands/auto-mode.md +15 -0
  81. package/commands/create-design.md +20 -0
  82. package/commands/create-diagram.md +16 -0
  83. package/commands/create-plan.md +22 -0
  84. package/commands/create-prd.md +16 -0
  85. package/commands/griling-plan.md +16 -0
  86. package/commands/griling-prd.md +16 -0
  87. package/commands/grilling-plan.md +16 -0
  88. package/commands/project-setup.md +16 -0
  89. package/commands/research.md +16 -0
  90. package/commands/sprint-meeting.md +16 -0
  91. package/dashboard/.agents/skills/coding-conventions/SKILL.md +76 -0
  92. package/dashboard/.agents/skills/coding-conventions/agents/openai.yaml +4 -0
  93. package/dashboard/.agents/skills/design-system-guideline/SKILL.md +51 -0
  94. package/dashboard/.agents/skills/design-system-guideline/agents/openai.yaml +4 -0
  95. package/dashboard/.agents/skills/lint-and-fix/SKILL.md +55 -0
  96. package/dashboard/.agents/skills/lint-and-fix/agents/openai.yaml +4 -0
  97. package/dashboard/.agents/skills/taste-ui/SKILL.md +45 -0
  98. package/dashboard/.agents/skills/taste-ui/agents/openai.yaml +4 -0
  99. package/dashboard/AGENTS.md +43 -0
  100. package/dashboard/bun.lock +352 -0
  101. package/dashboard/index.html +12 -0
  102. package/dashboard/package.json +32 -0
  103. package/dashboard/src/App.tsx +5 -0
  104. package/dashboard/src/features/task-status/components/ActionRequiredPanel/ActionRequiredPanel.module.css +85 -0
  105. package/dashboard/src/features/task-status/components/ActionRequiredPanel/ActionRequiredPanel.tsx +80 -0
  106. package/dashboard/src/features/task-status/components/ArtifactButton/ArtifactButton.module.css +25 -0
  107. package/dashboard/src/features/task-status/components/ArtifactButton/ArtifactButton.tsx +29 -0
  108. package/dashboard/src/features/task-status/components/ArtifactSummaryCards/ArtifactSummaryCards.module.css +29 -0
  109. package/dashboard/src/features/task-status/components/ArtifactSummaryCards/ArtifactSummaryCards.tsx +35 -0
  110. package/dashboard/src/features/task-status/components/CategoryPanel/CategoryPanel.module.css +85 -0
  111. package/dashboard/src/features/task-status/components/CategoryPanel/CategoryPanel.tsx +150 -0
  112. package/dashboard/src/features/task-status/components/DashboardHeader/DashboardHeader.module.css +41 -0
  113. package/dashboard/src/features/task-status/components/DashboardHeader/DashboardHeader.tsx +41 -0
  114. package/dashboard/src/features/task-status/components/FilesPanel/FilesPanel.module.css +25 -0
  115. package/dashboard/src/features/task-status/components/FilesPanel/FilesPanel.tsx +40 -0
  116. package/dashboard/src/features/task-status/components/HardnessEngineeringPanel/HardnessEngineeringPanel.module.css +330 -0
  117. package/dashboard/src/features/task-status/components/HardnessEngineeringPanel/HardnessEngineeringPanel.tsx +299 -0
  118. package/dashboard/src/features/task-status/components/LifecyclePanel/LifecyclePanel.module.css +74 -0
  119. package/dashboard/src/features/task-status/components/LifecyclePanel/LifecyclePanel.tsx +79 -0
  120. package/dashboard/src/features/task-status/components/MarkdownDialog/MarkdownDialog.module.css +133 -0
  121. package/dashboard/src/features/task-status/components/MarkdownDialog/MarkdownDialog.tsx +233 -0
  122. package/dashboard/src/features/task-status/components/Sidebar/Sidebar.module.css +53 -0
  123. package/dashboard/src/features/task-status/components/Sidebar/Sidebar.tsx +163 -0
  124. package/dashboard/src/features/task-status/components/StatusBadge/StatusBadge.module.css +41 -0
  125. package/dashboard/src/features/task-status/components/StatusBadge/StatusBadge.tsx +48 -0
  126. package/dashboard/src/features/task-status/components/TaskOverview/TaskOverview.module.css +97 -0
  127. package/dashboard/src/features/task-status/components/TaskOverview/TaskOverview.tsx +128 -0
  128. package/dashboard/src/features/task-status/components/TaskStatusDashboard/TaskStatusDashboard.module.css +9 -0
  129. package/dashboard/src/features/task-status/components/TaskStatusDashboard/TaskStatusDashboard.tsx +318 -0
  130. package/dashboard/src/features/task-status/components/WorkflowPanel/WorkflowPanel.module.css +221 -0
  131. package/dashboard/src/features/task-status/components/WorkflowPanel/WorkflowPanel.tsx +344 -0
  132. package/dashboard/src/features/task-status/taskStatusConfig.ts +100 -0
  133. package/dashboard/src/features/task-status/utils/actionItems.ts +247 -0
  134. package/dashboard/src/features/task-status/utils/artifactGrouping.ts +328 -0
  135. package/dashboard/src/features/task-status/utils/hardnessScanner.ts +406 -0
  136. package/dashboard/src/features/task-status/utils/lifecycle.ts +73 -0
  137. package/dashboard/src/features/task-status/utils/markdownInline/markdownInline.module.css +11 -0
  138. package/dashboard/src/features/task-status/utils/markdownInline/markdownInline.tsx +104 -0
  139. package/dashboard/src/features/task-status/utils/markdownLinks.ts +83 -0
  140. package/dashboard/src/features/task-status/utils/markdownRenderer/markdownRenderer.module.css +74 -0
  141. package/dashboard/src/features/task-status/utils/markdownRenderer/markdownRenderer.tsx +326 -0
  142. package/dashboard/src/features/task-status/utils/status.ts +7 -0
  143. package/dashboard/src/features/task-status/utils/test/actionItems.test.ts +134 -0
  144. package/dashboard/src/features/task-status/utils/test/artifactGrouping.test.ts +294 -0
  145. package/dashboard/src/features/task-status/utils/test/hardnessScanner.test.ts +138 -0
  146. package/dashboard/src/features/task-status/utils/test/lifecycle.test.ts +49 -0
  147. package/dashboard/src/features/task-status/utils/test/markdownInline.test.ts +41 -0
  148. package/dashboard/src/features/task-status/utils/test/markdownLinks.test.ts +158 -0
  149. package/dashboard/src/features/task-status/utils/test/workspaceMetadata.test.ts +37 -0
  150. package/dashboard/src/features/task-status/utils/workspaceMetadata.ts +175 -0
  151. package/dashboard/src/main.tsx +16 -0
  152. package/dashboard/src/shared/design-system.css +134 -0
  153. package/dashboard/src/shared/design-system.tsx +84 -0
  154. package/dashboard/src/styles.css +41 -0
  155. package/dashboard/src/types.ts +133 -0
  156. package/dashboard/src/workspace-artifacts.d.ts +9 -0
  157. package/dashboard/tsconfig.json +22 -0
  158. package/dashboard/vite.config.ts +579 -0
  159. package/designs/.gitkeep +1 -0
  160. package/docs/add-project-command-completion.md +117 -0
  161. package/docs/public-npm-registry-completion.md +104 -0
  162. package/docs/workflows.png +0 -0
  163. package/docs/workspace-template-setup.md +229 -0
  164. package/meeting-logs/.gitkeep +1 -0
  165. package/modules/.gitkeep +1 -0
  166. package/package.json +96 -5
  167. package/plans/.gitkeep +1 -0
  168. package/prds/.gitkeep +1 -0
  169. package/project/PROJECT.md +26 -0
  170. package/project/repositories.json +72 -0
  171. package/project/validation.json +9 -0
  172. package/project/workflows.json +20 -0
  173. package/research/.gitkeep +1 -0
  174. package/roles/backend-developer.md +26 -0
  175. package/roles/frontend-developer.md +25 -0
  176. package/roles/project-manager.md +42 -0
  177. package/roles/tech-lead.md +42 -0
  178. package/roles/ui-ux-designer.md +43 -0
  179. package/scripts/add-project.mjs +990 -0
  180. package/scripts/add-project.test.mjs +804 -0
  181. package/scripts/check-staged-security.mjs +97 -0
  182. package/scripts/check-staged-security.test.mjs +68 -0
  183. package/scripts/workspace-integrity.ts +220 -0
  184. package/templates/auto-mode-completion-summary-template.md +78 -0
  185. package/templates/meeting-log-template.md +177 -0
  186. package/templates/plan-template.md +219 -0
  187. package/templates/prd-template.md +106 -0
  188. package/templates/research-template.md +119 -0
  189. package/workflows.md +590 -0
  190. package/workspace.config.json +43 -0
@@ -0,0 +1,682 @@
1
+ import assert from "node:assert/strict";
2
+ import { spawnSync } from "node:child_process";
3
+ import fs from "node:fs";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import test from "node:test";
7
+ import { fileURLToPath } from "node:url";
8
+
9
+ const cli = fileURLToPath(new URL("./workflows.js", import.meta.url));
10
+
11
+ function run(root, ...args) {
12
+ return spawnSync(process.execPath, [cli, ...args, "--root", root], {
13
+ encoding: "utf8",
14
+ });
15
+ }
16
+
17
+ test("workspace check accepts formatting differences without changing files", (context) => {
18
+ // Resolve macOS temp aliases so Biome loads the fixture's actual config.
19
+ const root = fs.realpathSync(
20
+ fs.mkdtempSync(path.join(os.tmpdir(), "agent-workflows-check-")),
21
+ );
22
+ context.after(() => fs.rmSync(root, { recursive: true, force: true }));
23
+ const configPath = path.join(root, "workspace.config.json");
24
+ const config = {
25
+ artifactDirectories: ["prds", "plans", "designs", "research", "docs"],
26
+ };
27
+ for (const content of [
28
+ JSON.stringify(config),
29
+ JSON.stringify(config, null, 2),
30
+ ]) {
31
+ fs.writeFileSync(configPath, content);
32
+ const result = run(root, "check");
33
+ assert.equal(result.status, 0, result.stdout + result.stderr);
34
+ assert.equal(fs.readFileSync(configPath, "utf8"), content);
35
+ }
36
+
37
+ const biomeConfig = JSON.stringify({
38
+ formatter: { enabled: true },
39
+ overrides: [
40
+ { includes: ["workspace.config.json"], formatter: { enabled: true } },
41
+ ],
42
+ linter: {
43
+ rules: { preset: "recommended", suspicious: { noDebugger: "error" } },
44
+ },
45
+ });
46
+ fs.writeFileSync(path.join(root, "biome.json"), biomeConfig);
47
+ const sourcePath = path.join(root, "example.js");
48
+ const source = 'export const value={name:"example"}';
49
+ fs.writeFileSync(sourcePath, source);
50
+ const result = run(root, "check");
51
+ assert.equal(result.status, 0, result.stdout + result.stderr);
52
+ assert.equal(fs.readFileSync(sourcePath, "utf8"), source);
53
+ assert.equal(
54
+ fs.readFileSync(path.join(root, "biome.json"), "utf8"),
55
+ biomeConfig,
56
+ );
57
+
58
+ // Consumer lint rules must still reject actual code problems.
59
+ fs.writeFileSync(sourcePath, "debugger;\n");
60
+ const invalidSource = run(root, "check");
61
+ assert.equal(invalidSource.status, 1);
62
+ assert.match(invalidSource.stdout + invalidSource.stderr, /noDebugger/);
63
+ assert.equal(fs.readFileSync(sourcePath, "utf8"), "debugger;\n");
64
+
65
+ fs.writeFileSync(sourcePath, "export const value = ;\n");
66
+ const invalidSyntax = run(root, "check");
67
+ assert.equal(invalidSyntax.status, 1);
68
+ assert.match(invalidSyntax.stdout + invalidSyntax.stderr, /parse/);
69
+ assert.equal(fs.readFileSync(sourcePath, "utf8"), "export const value = ;\n");
70
+ });
71
+
72
+ test("workspace check preserves syntax, settings, and integrity failures", (context) => {
73
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "agent-workflows-check-"));
74
+ context.after(() => fs.rmSync(root, { recursive: true, force: true }));
75
+ const configPath = path.join(root, "workspace.config.json");
76
+ for (const [content, diagnostic] of [
77
+ ["{broken", /could not be read as JSON/],
78
+ ['{"autoMode":{"enabled":"yes"}}', /invalid autoMode configuration/],
79
+ ]) {
80
+ fs.writeFileSync(configPath, content);
81
+ const result = run(root, "check");
82
+ assert.equal(result.status, 1);
83
+ assert.match(result.stderr, diagnostic);
84
+ assert.equal(fs.readFileSync(configPath, "utf8"), content);
85
+ }
86
+ fs.writeFileSync(configPath, '{"artifactDirectories":["prds"]}');
87
+ fs.mkdirSync(path.join(root, "prds"));
88
+ const artifact =
89
+ "# Fixture\n\n- PRD ID: `PRD-20261102-duplicate`\n- Status: `draft`\n";
90
+ for (const name of ["first.md", "second.md"]) {
91
+ fs.writeFileSync(path.join(root, "prds", name), artifact);
92
+ }
93
+ const invalidArtifacts = run(root, "check");
94
+ assert.equal(invalidArtifacts.status, 1);
95
+ assert.match(
96
+ invalidArtifacts.stdout + invalidArtifacts.stderr,
97
+ /Duplicate artifact ID/,
98
+ );
99
+ });
100
+
101
+ test("workspace check validates model config keys and values", (context) => {
102
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "agent-workflows-check-"));
103
+ context.after(() => fs.rmSync(root, { recursive: true, force: true }));
104
+ const configPath = path.join(root, "workspace.config.json");
105
+
106
+ fs.writeFileSync(
107
+ configPath,
108
+ JSON.stringify({ agentModels: { "unknown-role": "inherit" } }, null, 2),
109
+ );
110
+ const invalidRole = run(root, "check");
111
+ assert.equal(invalidRole.status, 1);
112
+ assert.match(invalidRole.stderr, /unknown role "unknown-role"/);
113
+
114
+ fs.writeFileSync(
115
+ configPath,
116
+ JSON.stringify({ agentModels: { "tech-lead": "" } }, null, 2),
117
+ );
118
+ const invalidModel = run(root, "check");
119
+ assert.equal(invalidModel.status, 1);
120
+ assert.match(invalidModel.stderr, /invalid model/);
121
+ });
122
+
123
+ test("auto mode persists in workspace config and survives workflow updates", (context) => {
124
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "agent-workflows-auto-"));
125
+ context.after(() => fs.rmSync(root, { recursive: true, force: true }));
126
+ const configPath = path.join(root, "workspace.config.json");
127
+
128
+ assert.match(run(root, "auto", "status").stdout, /Auto mode: off/);
129
+ assert.equal(
130
+ JSON.parse(fs.readFileSync(configPath, "utf8")).autoMode.enabled,
131
+ false,
132
+ );
133
+ assert.equal(run(root, "init").status, 0);
134
+ assert.equal(run(root, "auto", "on").status, 0);
135
+ const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
136
+ config.projectNote = "keep this";
137
+ fs.writeFileSync(configPath, JSON.stringify(config));
138
+ assert.equal(run(root, "update").status, 0);
139
+ assert.match(run(root, "auto", "status").stdout, /Auto mode: on/);
140
+ assert.equal(
141
+ JSON.parse(fs.readFileSync(configPath, "utf8")).projectNote,
142
+ "keep this",
143
+ );
144
+ assert.match(run(root, "auto", "toggle").stdout, /Auto mode: off/);
145
+ assert.match(run(root, "auto", "toggle").stdout, /Auto mode: on/);
146
+ assert.match(run(root, "auto", "off").stdout, /Auto mode: off/);
147
+ assert.equal(
148
+ fs.existsSync(path.join(root, ".codex/prompts/auto-mode.md")),
149
+ true,
150
+ );
151
+ assert.equal(
152
+ fs.existsSync(path.join(root, ".claude/skills/auto-mode/SKILL.md")),
153
+ true,
154
+ );
155
+ });
156
+
157
+ test("legacy auto mode migrates to workspace config and keeps unrelated metadata", (context) => {
158
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "agent-workflows-auto-"));
159
+ context.after(() => fs.rmSync(root, { recursive: true, force: true }));
160
+ assert.equal(run(root, "init").status, 0);
161
+ const configPath = path.join(root, "workspace.config.json");
162
+ const configBeforeMigration = JSON.parse(fs.readFileSync(configPath, "utf8"));
163
+ delete configBeforeMigration.autoMode;
164
+ fs.writeFileSync(configPath, JSON.stringify(configBeforeMigration));
165
+ const legacyPath = path.join(root, ".agent-workflows/metadata.json");
166
+ fs.mkdirSync(path.dirname(legacyPath), { recursive: true });
167
+ fs.writeFileSync(
168
+ legacyPath,
169
+ JSON.stringify({
170
+ autoMode: { enabled: true, updatedAt: "2026-10-01T08:39:26.255Z" },
171
+ projectNote: "preserve me",
172
+ }),
173
+ );
174
+ assert.equal(run(root, "update").status, 0);
175
+ const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
176
+ assert.deepEqual(config.autoMode, {
177
+ enabled: true,
178
+ updatedAt: "2026-10-01T08:39:26.255Z",
179
+ });
180
+ assert.deepEqual(JSON.parse(fs.readFileSync(legacyPath, "utf8")), {
181
+ projectNote: "preserve me",
182
+ });
183
+ assert.match(run(root, "auto", "status").stdout, /Auto mode: on/);
184
+
185
+ const explicitConfig = { ...config, autoMode: { enabled: false } };
186
+ fs.writeFileSync(configPath, JSON.stringify(explicitConfig));
187
+ fs.writeFileSync(
188
+ legacyPath,
189
+ JSON.stringify({ autoMode: { enabled: true }, projectNote: "keep me too" }),
190
+ );
191
+ assert.equal(run(root, "update").status, 0);
192
+ assert.match(run(root, "auto", "status").stdout, /Auto mode: off/);
193
+ assert.deepEqual(JSON.parse(fs.readFileSync(legacyPath, "utf8")), {
194
+ projectNote: "keep me too",
195
+ });
196
+
197
+ const freshRoot = fs.mkdtempSync(
198
+ path.join(os.tmpdir(), "agent-workflows-auto-init-"),
199
+ );
200
+ context.after(() => fs.rmSync(freshRoot, { recursive: true, force: true }));
201
+ const freshLegacyPath = path.join(
202
+ freshRoot,
203
+ ".agent-workflows/metadata.json",
204
+ );
205
+ fs.mkdirSync(path.dirname(freshLegacyPath), { recursive: true });
206
+ fs.writeFileSync(
207
+ freshLegacyPath,
208
+ JSON.stringify({ autoMode: { enabled: true } }),
209
+ );
210
+ assert.equal(run(freshRoot, "init").status, 0);
211
+ assert.equal(
212
+ JSON.parse(
213
+ fs.readFileSync(path.join(freshRoot, "workspace.config.json"), "utf8"),
214
+ ).autoMode.enabled,
215
+ true,
216
+ );
217
+ assert.equal(fs.existsSync(freshLegacyPath), false);
218
+ });
219
+
220
+ test("invalid auto mode config fails closed without overwriting it", (context) => {
221
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "agent-workflows-auto-"));
222
+ context.after(() => fs.rmSync(root, { recursive: true, force: true }));
223
+ const target = path.join(root, "workspace.config.json");
224
+ fs.writeFileSync(target, '{"autoMode":{"enabled":"yes"}}');
225
+ const result = run(root, "auto", "on");
226
+ assert.equal(result.status, 1);
227
+ assert.match(result.stderr, /invalid autoMode configuration/);
228
+ assert.equal(
229
+ fs.readFileSync(target, "utf8"),
230
+ '{"autoMode":{"enabled":"yes"}}',
231
+ );
232
+ fs.writeFileSync(target, "{broken");
233
+ const malformed = run(root, "auto", "status");
234
+ assert.equal(malformed.status, 1);
235
+ assert.match(malformed.stderr, /could not be read as JSON/);
236
+ });
237
+
238
+ test("runtime-specific role models sync and survive legacy updates", (context) => {
239
+ const root = fs.mkdtempSync(
240
+ path.join(os.tmpdir(), "agent-workflows-models-"),
241
+ );
242
+ context.after(() => fs.rmSync(root, { recursive: true, force: true }));
243
+ assert.equal(run(root, "init").status, 0);
244
+ const configPath = path.join(root, "workspace.config.json");
245
+ const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
246
+ config.agentModels["tech-lead"] = {
247
+ antigravity: "pro",
248
+ claude: "example-claude-v2",
249
+ };
250
+ config.agentModels["frontend-developer"] = {
251
+ antigravity: "flash",
252
+ claude: "example-ui-3",
253
+ };
254
+ fs.writeFileSync(configPath, `${JSON.stringify(config, null, 2)}\n`);
255
+
256
+ const firstSync = run(root, "agents", "sync", "--format", "antigravity");
257
+ assert.equal(firstSync.status, 0, firstSync.stderr);
258
+ assert.match(
259
+ firstSync.stdout,
260
+ /tech-lead: antigravity=pro, claude=example-claude-v2 \(updated/,
261
+ );
262
+ for (const [role, agentsModel, claudeModel] of [
263
+ ["frontend-developer", "flash", "example-ui-3"],
264
+ ["project-manager", "inherit", "inherit"],
265
+ ]) {
266
+ assert.match(
267
+ fs.readFileSync(
268
+ path.join(root, `.agents/agents/${role}/agent.md`),
269
+ "utf8",
270
+ ),
271
+ new RegExp(`^model: ${agentsModel}$`, "m"),
272
+ );
273
+ assert.match(
274
+ fs.readFileSync(path.join(root, `.claude/agents/${role}.md`), "utf8"),
275
+ new RegExp(`^model: ${claudeModel}$`, "m"),
276
+ );
277
+ }
278
+ assert.match(
279
+ fs.readFileSync(
280
+ path.join(root, ".agents/agents/tech-lead/agent.md"),
281
+ "utf8",
282
+ ),
283
+ /^model: pro$/m,
284
+ );
285
+ assert.match(
286
+ fs.readFileSync(path.join(root, ".claude/agents/tech-lead.md"), "utf8"),
287
+ /^model: example-claude-v2$/m,
288
+ );
289
+ assert.match(
290
+ run(root, "agents", "sync", "--format", "antigravity").stdout,
291
+ /already up to date/,
292
+ );
293
+
294
+ const manifestPath = path.join(root, ".agent-workflows/manifest.json");
295
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
296
+ manifest.managedPaths.push("workspace.config.json");
297
+ fs.writeFileSync(manifestPath, JSON.stringify(manifest));
298
+ assert.equal(run(root, "update").status, 0);
299
+ assert.equal(
300
+ JSON.parse(fs.readFileSync(configPath, "utf8")).agentModels["tech-lead"]
301
+ .antigravity,
302
+ "pro",
303
+ );
304
+ assert.match(
305
+ fs.readFileSync(path.join(root, ".claude/agents/tech-lead.md"), "utf8"),
306
+ /^model: example-claude-v2$/m,
307
+ );
308
+
309
+ config.agentModels["tech-lead"] = "inherit";
310
+ fs.writeFileSync(configPath, JSON.stringify(config));
311
+ assert.equal(run(root, "agents", "sync").status, 0);
312
+ assert.match(
313
+ fs.readFileSync(
314
+ path.join(root, ".agents/agents/tech-lead/agent.md"),
315
+ "utf8",
316
+ ),
317
+ /^model: inherit$/m,
318
+ );
319
+ });
320
+
321
+ test("legacy agents and claude model objects remain readable during update", (context) => {
322
+ const root = fs.mkdtempSync(
323
+ path.join(os.tmpdir(), "agent-workflows-legacy-models-"),
324
+ );
325
+ context.after(() => fs.rmSync(root, { recursive: true, force: true }));
326
+ assert.equal(run(root, "init").status, 0);
327
+ const configPath = path.join(root, "workspace.config.json");
328
+ const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
329
+ config.agentModels["tech-lead"] = {
330
+ agents: "inherit",
331
+ claude: "sonnet",
332
+ };
333
+ config.workflowModels = {
334
+ planning: {
335
+ "tech-lead": { agents: "inherit", claude: "opus" },
336
+ },
337
+ };
338
+ fs.writeFileSync(configPath, JSON.stringify(config));
339
+ const update = run(root, "update");
340
+ assert.equal(update.status, 0, update.stderr);
341
+ assert.match(
342
+ fs.readFileSync(
343
+ path.join(root, ".agents/agents/tech-lead/agent.md"),
344
+ "utf8",
345
+ ),
346
+ /^model: inherit$/m,
347
+ );
348
+ assert.match(
349
+ fs.readFileSync(path.join(root, ".claude/agents/tech-lead.md"), "utf8"),
350
+ /^model: sonnet$/m,
351
+ );
352
+ const resolve = (format) => {
353
+ const result = run(
354
+ root,
355
+ "agents",
356
+ "resolve",
357
+ "planning",
358
+ "tech-lead",
359
+ "--format",
360
+ format,
361
+ "--json",
362
+ );
363
+ assert.equal(result.status, 0, result.stderr);
364
+ return JSON.parse(result.stdout).model;
365
+ };
366
+ assert.equal(resolve("agents"), "inherit");
367
+ assert.equal(resolve("claude"), "opus");
368
+ });
369
+
370
+ test("invalid role model configuration leaves agent definitions unchanged", (context) => {
371
+ const root = fs.mkdtempSync(
372
+ path.join(os.tmpdir(), "agent-workflows-models-"),
373
+ );
374
+ context.after(() => fs.rmSync(root, { recursive: true, force: true }));
375
+ assert.equal(run(root, "init").status, 0);
376
+ const configPath = path.join(root, "workspace.config.json");
377
+ const agentPath = path.join(root, ".agents/agents/tech-lead/agent.md");
378
+ const before = fs.readFileSync(agentPath, "utf8");
379
+ const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
380
+ config.agentModels["tech-lead"] = "invalid model\nname";
381
+ fs.writeFileSync(configPath, JSON.stringify(config));
382
+ const invalidValue = run(root, "agents", "sync");
383
+ assert.equal(invalidValue.status, 1);
384
+ assert.match(invalidValue.stderr, /agentModels\.tech-lead has invalid model/);
385
+ assert.equal(fs.readFileSync(agentPath, "utf8"), before);
386
+ assert.equal(run(root, "update").status, 1);
387
+ assert.equal(fs.readFileSync(agentPath, "utf8"), before);
388
+
389
+ config.agentModels["tech-lead"] = "inherit";
390
+ config.agentModels.unknown = "inherit";
391
+ fs.writeFileSync(configPath, JSON.stringify(config));
392
+ assert.match(run(root, "agents", "sync").stderr, /unknown role/);
393
+ assert.equal(fs.readFileSync(agentPath, "utf8"), before);
394
+ config.agentModels = null;
395
+ fs.writeFileSync(configPath, JSON.stringify(config));
396
+ assert.match(
397
+ run(root, "agents", "sync").stderr,
398
+ /agentModels must be an object/,
399
+ );
400
+ assert.equal(fs.readFileSync(agentPath, "utf8"), before);
401
+ fs.writeFileSync(configPath, "{broken");
402
+ assert.match(run(root, "agents", "sync").stderr, /could not be read as JSON/);
403
+ assert.equal(fs.readFileSync(agentPath, "utf8"), before);
404
+ });
405
+
406
+ test("workflow steps override role models with source attribution", (context) => {
407
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "agent-workflows-steps-"));
408
+ context.after(() => fs.rmSync(root, { recursive: true, force: true }));
409
+ assert.equal(run(root, "init").status, 0);
410
+ const configPath = path.join(root, "workspace.config.json");
411
+ const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
412
+ config.agentModels["tech-lead"] = {
413
+ antigravity: "flash",
414
+ claude: "base-claude",
415
+ };
416
+ config.workflowModels = {
417
+ planning: {
418
+ default: { antigravity: "pro" },
419
+ "tech-lead": { antigravity: "flash", claude: "planning-claude" },
420
+ },
421
+ coding: { "tech-lead": { antigravity: "pro" } },
422
+ validation: { "tech-lead": { antigravity: "inherit" } },
423
+ };
424
+ fs.writeFileSync(configPath, JSON.stringify(config));
425
+ const resolve = (step, role, format) => {
426
+ const result = run(
427
+ root,
428
+ "agents",
429
+ "resolve",
430
+ step,
431
+ role,
432
+ "--format",
433
+ format,
434
+ "--json",
435
+ );
436
+ assert.equal(result.status, 0, result.stderr);
437
+ return JSON.parse(result.stdout);
438
+ };
439
+ assert.deepEqual(resolve("planning", "tech-lead", "antigravity"), {
440
+ step: "planning",
441
+ role: "tech-lead",
442
+ format: "antigravity",
443
+ model: "flash",
444
+ source: "workflowModels.planning.tech-lead",
445
+ });
446
+ assert.equal(
447
+ resolve("planning", "tech-lead", "claude").model,
448
+ "planning-claude",
449
+ );
450
+ assert.equal(resolve("coding", "tech-lead", "antigravity").model, "pro");
451
+ assert.equal(
452
+ resolve("planning", "frontend-developer", "antigravity").model,
453
+ "pro",
454
+ );
455
+ assert.equal(resolve("research", "tech-lead", "antigravity").model, "flash");
456
+ assert.deepEqual(
457
+ [
458
+ resolve("validation", "tech-lead", "antigravity").model,
459
+ resolve("validation", "tech-lead", "antigravity").source,
460
+ ],
461
+ ["inherit", "workflowModels.validation.tech-lead"],
462
+ );
463
+ assert.match(
464
+ run(
465
+ root,
466
+ "agents",
467
+ "resolve",
468
+ "planning",
469
+ "tech-lead",
470
+ "--format",
471
+ "antigravity",
472
+ ).stdout,
473
+ /flash \(source: workflowModels\.planning\.tech-lead; runtime: antigravity\)/,
474
+ );
475
+ assert.match(
476
+ run(root, "agents", "resolve", "unknown", "tech-lead", "--format", "agents")
477
+ .stderr,
478
+ /Unknown workflow step/,
479
+ );
480
+ assert.match(
481
+ run(root, "agents", "resolve", "planning", "unknown", "--format", "agents")
482
+ .stderr,
483
+ /Unknown agent role/,
484
+ );
485
+ assert.match(
486
+ run(root, "agents", "resolve", "planning", "tech-lead", "--format", "other")
487
+ .stderr,
488
+ /--format must be codex, antigravity, or claude/,
489
+ );
490
+ });
491
+
492
+ test("invalid workflow override fails before agent files change", (context) => {
493
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "agent-workflows-steps-"));
494
+ context.after(() => fs.rmSync(root, { recursive: true, force: true }));
495
+ assert.equal(run(root, "init").status, 0);
496
+ const configPath = path.join(root, "workspace.config.json");
497
+ const agentPath = path.join(root, ".agents/agents/tech-lead/agent.md");
498
+ const before = fs.readFileSync(agentPath, "utf8");
499
+ const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
500
+ config.workflowModels = { planning: { "tech-lead": { agents: "partial" } } };
501
+ fs.writeFileSync(configPath, JSON.stringify(config));
502
+ assert.match(
503
+ run(root, "agents", "sync").stderr,
504
+ /workflowModels\.planning\.tech-lead must use codex, antigravity, and\/or claude model keys/,
505
+ );
506
+ assert.equal(run(root, "update").status, 1);
507
+ assert.equal(fs.readFileSync(agentPath, "utf8"), before);
508
+ config.workflowModels = { unknown: { default: "inherit" } };
509
+ fs.writeFileSync(configPath, JSON.stringify(config));
510
+ assert.match(run(root, "agents", "sync").stderr, /unknown step/);
511
+ assert.equal(fs.readFileSync(agentPath, "utf8"), before);
512
+ });
513
+
514
+ test("Antigravity model tiers are listed and invalid tiers fall back to inherit", (context) => {
515
+ const root = fs.mkdtempSync(
516
+ path.join(os.tmpdir(), "agent-workflows-antigravity-models-"),
517
+ );
518
+ context.after(() => fs.rmSync(root, { recursive: true, force: true }));
519
+ assert.equal(run(root, "init").status, 0);
520
+ const configPath = path.join(root, "workspace.config.json");
521
+ const config = JSON.parse(fs.readFileSync(configPath, "utf8"));
522
+ config.workflowModels = {
523
+ coding: { "tech-lead": { antigravity: "enterprise" } },
524
+ };
525
+ fs.writeFileSync(configPath, JSON.stringify(config));
526
+ const invalidModel = run(
527
+ root,
528
+ "agents",
529
+ "resolve",
530
+ "coding",
531
+ "tech-lead",
532
+ "--format",
533
+ "antigravity",
534
+ "--json",
535
+ );
536
+ assert.equal(invalidModel.status, 0, invalidModel.stderr);
537
+ assert.match(invalidModel.stderr, /not a supported Antigravity model tier/);
538
+ assert.deepEqual(JSON.parse(invalidModel.stdout), {
539
+ step: "coding",
540
+ role: "tech-lead",
541
+ format: "antigravity",
542
+ model: "inherit",
543
+ source: "invalid model fallback (runtime default)",
544
+ });
545
+ const models = run(
546
+ root,
547
+ "agents",
548
+ "models",
549
+ "--format",
550
+ "antigravity",
551
+ "--json",
552
+ );
553
+ assert.deepEqual(JSON.parse(models.stdout), {
554
+ format: "antigravity",
555
+ models: ["inherit", "flash", "pro"],
556
+ });
557
+ });
558
+
559
+ test("update backfills visible model defaults in legacy configs without replacing choices", (context) => {
560
+ const root = fs.mkdtempSync(
561
+ path.join(os.tmpdir(), "agent-workflows-upgrade-"),
562
+ );
563
+ context.after(() => fs.rmSync(root, { recursive: true, force: true }));
564
+ assert.equal(run(root, "init").status, 0);
565
+ const configPath = path.join(root, "workspace.config.json");
566
+ fs.writeFileSync(
567
+ configPath,
568
+ JSON.stringify({
569
+ projectName: "Legacy project",
570
+ customSetting: { keep: true },
571
+ }),
572
+ );
573
+ const first = run(root, "update");
574
+ assert.equal(first.status, 0, first.stderr);
575
+ assert.match(first.stdout, /Added missing model defaults/);
576
+ const migrated = JSON.parse(fs.readFileSync(configPath, "utf8"));
577
+ assert.equal(migrated.projectName, "Legacy project");
578
+ assert.deepEqual(migrated.customSetting, { keep: true });
579
+ const inheritedModels = {
580
+ codex: "inherit",
581
+ antigravity: "inherit",
582
+ claude: "inherit",
583
+ };
584
+ assert.deepEqual(migrated.agentModels, {
585
+ "project-manager": inheritedModels,
586
+ "tech-lead": inheritedModels,
587
+ "ui-ux-designer": inheritedModels,
588
+ "backend-developer": inheritedModels,
589
+ "frontend-developer": inheritedModels,
590
+ });
591
+ assert.deepEqual(migrated.workflowModels, { planning: {}, coding: {} });
592
+
593
+ fs.writeFileSync(
594
+ configPath,
595
+ JSON.stringify({
596
+ projectName: "Legacy project",
597
+ customSetting: { keep: true },
598
+ agentModels: { "tech-lead": "chosen-model" },
599
+ workflowModels: { planning: { "tech-lead": "planning-model" } },
600
+ }),
601
+ );
602
+ const second = run(root, "update");
603
+ assert.equal(second.status, 0, second.stderr);
604
+ const partial = JSON.parse(fs.readFileSync(configPath, "utf8"));
605
+ assert.equal(partial.agentModels["tech-lead"], "chosen-model");
606
+ assert.deepEqual(partial.agentModels["backend-developer"], inheritedModels);
607
+ assert.equal(partial.workflowModels.planning["tech-lead"], "planning-model");
608
+ assert.deepEqual(partial.workflowModels.coding, {});
609
+ const textAfterMigration = fs.readFileSync(configPath, "utf8");
610
+ const third = run(root, "update");
611
+ assert.equal(third.status, 0, third.stderr);
612
+ assert.doesNotMatch(third.stdout, /Added missing model defaults/);
613
+ assert.equal(fs.readFileSync(configPath, "utf8"), textAfterMigration);
614
+ });
615
+
616
+ test("add-project discovery installs and updates without replacing project data", (context) => {
617
+ const root = fs.mkdtempSync(
618
+ path.join(os.tmpdir(), "agent-workflows-add-project-"),
619
+ );
620
+ context.after(() => fs.rmSync(root, { recursive: true, force: true }));
621
+ const initialized = run(root, "init");
622
+ assert.equal(initialized.status, 0, initialized.stderr);
623
+ for (const relative of [
624
+ ".agents/skills/add-project/SKILL.md",
625
+ ".agents/skills/add-project/references/save-protocol.md",
626
+ ".codex/prompts/add-project.md",
627
+ ".claude/skills/add-project/SKILL.md",
628
+ "commands/add-project.md",
629
+ ]) {
630
+ assert.equal(fs.existsSync(path.join(root, relative)), true, relative);
631
+ }
632
+ const profilePath = path.join(root, "project/repositories.json");
633
+ const profile = { repositories: [], custom: "keep developer configuration" };
634
+ fs.writeFileSync(profilePath, JSON.stringify(profile));
635
+ const refreshed = run(root, "update");
636
+ assert.equal(refreshed.status, 0, refreshed.stderr);
637
+ assert.deepEqual(JSON.parse(fs.readFileSync(profilePath, "utf8")), profile);
638
+ const skillShim = fs.readFileSync(
639
+ path.join(root, ".agents/skills/add-project/SKILL.md"),
640
+ "utf8",
641
+ );
642
+ assert.match(skillShim, /packaged/i);
643
+ assert.match(skillShim, /add-project/);
644
+ assert.equal(
645
+ fs.existsSync(path.join(root, "scripts/add-project.mjs")),
646
+ false,
647
+ );
648
+ });
649
+
650
+ test("packaged add-project helper targets a consumer rather than the source template", (context) => {
651
+ const root = fs.mkdtempSync(
652
+ path.join(os.tmpdir(), "agent-workflows-add-consumer-"),
653
+ );
654
+ context.after(() => fs.rmSync(root, { recursive: true, force: true }));
655
+ const sourceProfile = fileURLToPath(
656
+ new URL("../project/repositories.json", import.meta.url),
657
+ );
658
+ const sourceBefore = fs.readFileSync(sourceProfile, "utf8");
659
+ assert.equal(run(root, "init").status, 0);
660
+ const initializedGit = spawnSync("git", ["init", root], { encoding: "utf8" });
661
+ assert.equal(initializedGit.status, 0, initializedGit.stderr);
662
+ const profilePath = path.join(root, "project/repositories.json");
663
+ const profileBefore = fs.readFileSync(profilePath, "utf8");
664
+ const request = path.join(root, "empty-request.json");
665
+ fs.writeFileSync(request, JSON.stringify({ entries: [] }));
666
+ const helper = fileURLToPath(
667
+ new URL("../scripts/add-project.mjs", import.meta.url),
668
+ );
669
+ const result = spawnSync(
670
+ process.execPath,
671
+ [helper, "save", "--root", root, "--request", request],
672
+ {
673
+ cwd: root,
674
+ encoding: "utf8",
675
+ },
676
+ );
677
+ assert.equal(result.status, 0, result.stdout + result.stderr);
678
+ assert.equal(JSON.parse(result.stdout).status, "empty");
679
+ assert.equal(fs.readFileSync(profilePath, "utf8"), profileBefore);
680
+ assert.equal(fs.readFileSync(sourceProfile, "utf8"), sourceBefore);
681
+ assert.equal(fs.existsSync(path.join(root, ".gitmodules")), false);
682
+ });