wildcrane 0.11.30 → 0.11.31

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 (4) hide show
  1. package/LICENSE +201 -104
  2. package/README.md +1 -1
  3. package/dist/kanban.mjs +159 -89
  4. package/package.json +2 -2
package/LICENSE CHANGED
@@ -1,105 +1,202 @@
1
- # Functional Source License, Version 1.1, ALv2 Future License
2
1
 
3
- ## Abbreviation
4
-
5
- FSL-1.1-ALv2
6
-
7
- ## Notice
8
-
9
- Copyright 2026 Tao Wu
10
-
11
- ## Terms and Conditions
12
-
13
- ### Licensor ("We")
14
-
15
- The party offering the Software under these Terms and Conditions.
16
-
17
- ### The Software
18
-
19
- The "Software" is each version of the software that we make available under
20
- these Terms and Conditions, as indicated by our inclusion of these Terms and
21
- Conditions with the Software.
22
-
23
- ### License Grant
24
-
25
- Subject to your compliance with this License Grant and the Patents,
26
- Redistribution and Trademark clauses below, we hereby grant you the right to
27
- use, copy, modify, create derivative works, publicly perform, publicly display
28
- and redistribute the Software for any Permitted Purpose identified below.
29
-
30
- ### Permitted Purpose
31
-
32
- A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
- means making the Software available to others in a commercial product or
34
- service that:
35
-
36
- 1. substitutes for the Software;
37
-
38
- 2. substitutes for any other product or service we offer using the Software
39
- that exists as of the date we make the Software available; or
40
-
41
- 3. offers the same or substantially similar functionality as the Software.
42
-
43
- Permitted Purposes specifically include using the Software:
44
-
45
- 1. for your internal use and access;
46
-
47
- 2. for non-commercial education;
48
-
49
- 3. for non-commercial research; and
50
-
51
- 4. in connection with professional services that you provide to a licensee
52
- using the Software in accordance with these Terms and Conditions.
53
-
54
- ### Patents
55
-
56
- To the extent your use for a Permitted Purpose would necessarily infringe our
57
- patents, the license grant above includes a license under our patents. If you
58
- make a claim against any party that the Software infringes or contributes to
59
- the infringement of any patent, then your patent license to the Software ends
60
- immediately.
61
-
62
- ### Redistribution
63
-
64
- The Terms and Conditions apply to all copies, modifications and derivatives of
65
- the Software.
66
-
67
- If you redistribute any copies, modifications or derivatives of the Software,
68
- you must include a copy of or a link to these Terms and Conditions and not
69
- remove any copyright notices provided in or with the Software.
70
-
71
- ### Disclaimer
72
-
73
- THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
- IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
- PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
-
77
- IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
- SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
- EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
-
81
- ### Trademarks
82
-
83
- Except for displaying the License Details and identifying us as the origin of
84
- the Software, you have no right under these Terms and Conditions to use our
85
- trademarks, trade names, service marks or product names.
86
-
87
- ## Grant of Future License
88
-
89
- We hereby irrevocably grant you an additional license to use the Software under
90
- the Apache License, Version 2.0 that is effective on the second anniversary of
91
- the date we make the Software available. On or after that date, you may use the
92
- Software under the Apache License, Version 2.0, in which case the following
93
- will apply:
94
-
95
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
- this file except in compliance with the License.
97
-
98
- You may obtain a copy of the License at
99
-
100
- http://www.apache.org/licenses/LICENSE-2.0
101
-
102
- Unless required by applicable law or agreed to in writing, software distributed
103
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
- CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
- specific language governing permissions and limitations under the License.
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -16,7 +16,7 @@ Still on the old `ai4kanban` package? Run `npm uninstall -g ai4kanban` first; bo
16
16
 
17
17
  Run `akb help` for commands and `akb guide` for workflows.
18
18
 
19
- 通过插件连接云端项目。`akb install` 和整个 `akb skill` 命令树已移除;kanban 技能随插件提供。
19
+ 通过插件连接云端项目。`akb install` 和整个 `akb skill` 命令树已移除;kanban 技能由 Runner 在绑定目录时写入项目。
20
20
  `akb update` 只修复已有看板并检查 CLI 新版本,不安装技能或钩子。
21
21
 
22
22
  ## 讨论目标
package/dist/kanban.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // ai4kanban 0.11.30 — built from the CLI's TypeScript sources by cli/scripts/build.mjs.
2
+ // ai4kanban 0.11.31 — built from the CLI's TypeScript sources by cli/scripts/build.mjs.
3
3
  // Do not edit: every change belongs in cli/src/, and a build overwrites this file.
4
4
  import { createRequire as __ai4kanbanRequire } from 'node:module'
5
5
  const require = __ai4kanbanRequire(import.meta.url)
@@ -2328,6 +2328,12 @@ function eventModel(ev) {
2328
2328
  return void 0;
2329
2329
  }
2330
2330
  function whyItFailed(ev) {
2331
+ const why2 = failedWith(ev);
2332
+ const fix = USER_FIXES.find(([pattern]) => pattern.test(why2))?.[1];
2333
+ return fix ? `${why2}
2334
+ ${fix}` : why2;
2335
+ }
2336
+ function failedWith(ev) {
2331
2337
  const errors = Array.isArray(ev.errors) ? ev.errors.map(str).filter(Boolean) : [];
2332
2338
  if (errors.length) return errors.join("; ");
2333
2339
  const named2 = str(ev.subtype) || str(ev.terminal_reason);
@@ -2468,7 +2474,7 @@ function usageOf(raw) {
2468
2474
  };
2469
2475
  return parsed.input + parsed.cacheCreation + parsed.cacheRead + parsed.output > 0 ? parsed : void 0;
2470
2476
  }
2471
- var ARG_KEYS, TOOL_KINDS2, addUsage;
2477
+ var ARG_KEYS, TOOL_KINDS2, USER_FIXES, addUsage;
2472
2478
  var init_claude_stream = __esm({
2473
2479
  "src/lib/agent/wire/claude-stream.ts"() {
2474
2480
  "use strict";
@@ -2488,6 +2494,10 @@ var init_claude_stream = __esm({
2488
2494
  WebFetch: "fetch",
2489
2495
  WebSearch: "fetch"
2490
2496
  };
2497
+ USER_FIXES = [
2498
+ [/failed to authenticate|invalid api key|oauth token|please run \/login|not logged in/i, "Sign in to Claude Code again: run `claude` and enter /login."],
2499
+ [/usage limit|credit balance is too low|quota/i, "Wait for the usage limit to reset, or add credit, then press Resume."]
2500
+ ];
2491
2501
  addUsage = (a2, b2) => ({
2492
2502
  input: a2.input + b2.input,
2493
2503
  cacheCreation: a2.cacheCreation + b2.cacheCreation,
@@ -3244,7 +3254,7 @@ var init_package = __esm({
3244
3254
  "package.json"() {
3245
3255
  package_default = {
3246
3256
  name: "wildcrane",
3247
- version: "0.11.30",
3257
+ version: "0.11.31",
3248
3258
  akbContract: 7,
3249
3259
  description: "WildCrane's `akb` command \u2014 scaffold the Markdown board under docs/kanban/, put an agent on a card, and carry the flows the agent works by.",
3250
3260
  keywords: [
@@ -3257,7 +3267,7 @@ var init_package = __esm({
3257
3267
  "markdown",
3258
3268
  "board"
3259
3269
  ],
3260
- license: "FSL-1.1-ALv2",
3270
+ license: "Apache-2.0",
3261
3271
  homepage: "https://wildcrane.ai/",
3262
3272
  repository: {
3263
3273
  type: "git",
@@ -9643,7 +9653,7 @@ function writeDraft(def, settings) {
9643
9653
  function renameWorkflow(id, name) {
9644
9654
  const draft = draftId();
9645
9655
  if (!draft) return readOnly();
9646
- if (id !== draft) return { ok: false, ...refusal("workflowReadOnly", `only the draft, \`${draft}\`, is edited here; workflows are edited on the web`, { id }) };
9656
+ if (id !== draft) return { ok: false, ...refusal("workflowReadOnly", `only the draft, \`${draft}\`, is renamed here`, { id }) };
9647
9657
  const wanted = trimmedName(name);
9648
9658
  if (!wanted) return { ok: false, ...refusal("workflowUnnamed", "a workflow needs a name") };
9649
9659
  if (nameTaken(wanted, id)) return { ok: false, ...refusal("workflowTaken", `this workspace already has a workflow called "${wanted}"`, { name: wanted }) };
@@ -9814,7 +9824,7 @@ var init_workflows = __esm({
9814
9824
  });
9815
9825
  draftDef = (id) => boardWorkflowDefs().defs.find((d2) => d2.id === id);
9816
9826
  notFound = (id) => ({ ok: false, ...refusal("workflowNotFound", `this board has no \`${id}\` workflow`, { id }) });
9817
- readOnly = () => ({ ok: false, ...refusal("workflowReadOnly", "Workflows are edited on the web.") });
9827
+ readOnly = () => ({ ok: false, ...refusal("workflowReadOnly", "Only a Workflow builder draft is renamed here; change a workflow with `akb workflow pull` and `push`.") });
9818
9828
  trimmedName = (name) => name.replace(/\s+/g, " ").trim();
9819
9829
  nameTaken = (name, except = "") => workflows().some((w2) => w2.id !== except && trimmedName(w2.name).toLowerCase() === trimmedName(name).toLowerCase());
9820
9830
  scheduledAgent = (id, agent) => {
@@ -9966,6 +9976,14 @@ import fs31 from "node:fs";
9966
9976
  import os4 from "node:os";
9967
9977
  import path34 from "node:path";
9968
9978
  import crypto3 from "node:crypto";
9979
+ function hostSession() {
9980
+ const { CLAUDE_CODE_SESSION_ID: claude, CODEX_THREAD_ID: codex, CURSOR_CONVERSATION_ID: cursor, KIMI_SESSION_ID: kimi, WILDCRANE_DISCUSSION: discussion2 } = process.env;
9981
+ if (discussion2) return { id: discussion2, host: "discussion" };
9982
+ if (claude) return { id: claude, host: "claude-code" };
9983
+ if (codex) return { id: codex, host: "codex" };
9984
+ if (cursor) return { id: cursor, host: "cursor" };
9985
+ return kimi ? { id: kimi, host: "kimi" } : null;
9986
+ }
9969
9987
  async function request(method, route2, body) {
9970
9988
  if (externalGoalSession()) process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME || path34.join(os4.homedir(), ".wildcrane");
9971
9989
  const token3 = await accessToken();
@@ -9997,10 +10015,11 @@ function goalsOf(d2) {
9997
10015
  return goals;
9998
10016
  }
9999
10017
  async function discussion() {
10000
- const session = process.env.CLAUDE_CODE_SESSION_ID || process.env.CODEX_THREAD_ID;
10018
+ const session = hostSession();
10001
10019
  if (!session) die("Goals exist only inside a WildCrane goal discussion.");
10002
10020
  const home3 = process.env.WILDCRANE_HOME || path34.join(os4.homedir(), ".wildcrane");
10003
10021
  process.env.AI4KANBAN_HOME ??= home3;
10022
+ if (session.host === "discussion") return request("GET", `/v1/discussions/${encodeURIComponent(session.id)}`);
10004
10023
  const machineFile2 = path34.join(home3, "machine.json");
10005
10024
  let machine;
10006
10025
  try {
@@ -10020,7 +10039,7 @@ async function discussion() {
10020
10039
  return false;
10021
10040
  }
10022
10041
  }).sort((a2, b2) => b2.path.length - a2.path.length)[0];
10023
- return request("POST", "/v1/discussions/external", { requestId: session, host: process.env.CLAUDE_CODE_SESSION_ID ? "claude-code" : "codex", ...folder ? { project: folder.project } : {} });
10042
+ return request("POST", "/v1/discussions/external", { requestId: session.id, host: session.host, ...folder ? { project: folder.project } : {} });
10024
10043
  }
10025
10044
  async function withGoalDiscussion(action, save3 = false) {
10026
10045
  const d2 = await discussion();
@@ -10078,7 +10097,7 @@ var init_goal_cloud = __esm({
10078
10097
  init_paths();
10079
10098
  init_io();
10080
10099
  init_goal();
10081
- externalGoalSession = () => !goalsFile() && !process.env.KANBAN_RUN && !process.env.WILDCRANE_JOB && !process.env.AI4KANBAN_BOARD && Boolean(process.env.CLAUDE_CODE_SESSION_ID || process.env.CODEX_THREAD_ID);
10100
+ externalGoalSession = () => !goalsFile() && !process.env.KANBAN_RUN && !process.env.WILDCRANE_JOB && !process.env.AI4KANBAN_BOARD && Boolean(hostSession());
10082
10101
  cloudGoal = (args, opts) => withGoalDiscussion(() => cmdGoal(args, opts), true);
10083
10102
  cloudGoalWorkflows = () => withGoalDiscussion(cmdGoalWorkflows);
10084
10103
  }
@@ -15215,7 +15234,7 @@ var init_Asset = __esm({
15215
15234
  var Compare_default;
15216
15235
  var init_Compare = __esm({
15217
15236
  "src/components/Compare.md"() {
15218
- Compare_default = '# Compare\n\nShow two images or videos with `<Compare a="<src>" b="<src>" label="..." a-label="..." b-label="..." />` alone in a paragraph; never render a side-by-side file for it. Inline and fenced examples remain text.\n\n- **Video shots**: add `shots="<src>"`, a JSON list of `{ "id": "S1", "start": 0, "end": 2.25, "name": "..." }` covering video A in order, or a storyboard of A.\n- **Storyboard pairing**: B may be a storyboard instead of a video; it shows the shot with the id A is on, beside that shot of a storyboard `shots`.\n- **Data contract**: follow the producing agent\'s file contract and validator for storyboards.\n';
15237
+ Compare_default = '# Compare\n\nShow two files with `<Compare a="<src>" b="<src>" label="..." a-label="..." b-label="..." />` alone in a paragraph; never render a side-by-side file for it. Inline and fenced examples remain text.\n\n- **Sides**: either side may be anything an Asset shows, of different kinds, but not another compare; two images or two videos share one viewer, any other pair shows as two Assets.\n- **Video shots**: add `shots="<src>"`, a JSON list of `{ "id": "S1", "start": 0, "end": 2.25, "name": "..." }` covering video A in order, or a storyboard of A.\n- **Storyboard pairing**: beside video A, B may be a storyboard of it; it shows the shot with the id A is on, beside that shot of a storyboard `shots`.\n- **Data contract**: follow the producing agent\'s file contract and validator for storyboards.\n';
15219
15238
  }
15220
15239
  });
15221
15240
 
@@ -15223,7 +15242,7 @@ var init_Compare = __esm({
15223
15242
  var Storyboard_default;
15224
15243
  var init_Storyboard = __esm({
15225
15244
  "src/components/Storyboard.md"() {
15226
- Storyboard_default = '# Storyboard\n\nShow a sequence with `<Storyboard src=".assets/<card id>/<storyboard>.json" label="..." />` alone in a paragraph; `label` is optional. Inline and fenced examples remain text.\n\n- **Data contract**: follow the producing agent\'s storyboard contract and validator for its shots or slides, keeping stable IDs and reachable preview files.\n';
15245
+ Storyboard_default = '# Storyboard\n\nShow a sequence with `<Storyboard src=".assets/<card id>/<storyboard>.json" label="..." />` alone in a paragraph; `label` is optional. Inline and fenced examples remain text.\n\n- **Frames**: a shot frame or slide preview may be anything an Asset shows, but not a storyboard or compare.\n- **Data contract**: follow the producing agent\'s storyboard contract and validator for its shots or slides, keeping stable IDs and reachable preview files.\n';
15227
15246
  }
15228
15247
  });
15229
15248
 
@@ -16237,7 +16256,8 @@ function endedDeliveryRefusal(r2, refusals) {
16237
16256
  if (refusals?.has(r2.deliveryId)) return refusals.get(r2.deliveryId);
16238
16257
  const delivery = findDelivery(r2.deliveryId);
16239
16258
  const ended = delivery && delivery.status !== "active" && (delivery.status !== "failed" || delivery.worktree);
16240
- const why2 = ended ? resumeRefusal(delivery) : void 0;
16259
+ const repairsShipped = !!r2.formatRepair && delivery?.status === "finished";
16260
+ const why2 = ended && !repairsShipped ? resumeRefusal(delivery) : void 0;
16241
16261
  refusals?.set(r2.deliveryId, why2);
16242
16262
  return why2;
16243
16263
  }
@@ -16750,6 +16770,7 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
16750
16770
  if (locked) return locked;
16751
16771
  all2.push(record);
16752
16772
  const delivery = store.deliveries.find((d2) => d2.deliveryId === prev.deliveryId && d2.status === "active");
16773
+ if (!delivery && record.formatRepair) record.deliveryId = prev.deliveryId;
16753
16774
  if (delivery) {
16754
16775
  delivery.sessions.push(record.sessionId);
16755
16776
  delivery.steps.push({ step: "resume", at: record.startedAt });
@@ -17770,7 +17791,7 @@ function storyboardMarkers(body, tagOf = storyboardTag) {
17770
17791
  return found2;
17771
17792
  }
17772
17793
  function assetName(src, cardId2, exts, nested = false) {
17773
- const expected = `.assets/${cardId2}/<file>.${exts.length === 1 ? exts[0] : `{${exts.join(",")}}`} in this card's asset folder`;
17794
+ const expected = `.assets/${cardId2}/<file>${!exts.length ? "" : `.${exts.length === 1 ? exts[0] : `{${exts.join(",")}}`}`} in this card's asset folder`;
17774
17795
  if (/^[a-z][a-z0-9+.-]*:/i.test(src)) return { expected, actual: `an external address ${JSON.stringify(src)}` };
17775
17796
  const parts = src.split("/");
17776
17797
  if (parts[0] !== ".assets" || parts.length < 3 || !nested && parts.length !== 3) return { expected, actual: JSON.stringify(src) };
@@ -17778,7 +17799,7 @@ function assetName(src, cardId2, exts, nested = false) {
17778
17799
  if (!parts.slice(2).every((part) => SEGMENT2.test(part))) return { expected, actual: JSON.stringify(src) };
17779
17800
  const name = parts.slice(2).join("/");
17780
17801
  const ext = name.split(".").pop().toLowerCase();
17781
- if (!name.includes(".") || !exts.includes(ext)) return { expected, actual: `file type ${JSON.stringify(name.includes(".") ? ext : "")}` };
17802
+ if (exts.length && (!name.includes(".") || !exts.includes(ext))) return { expected, actual: `file type ${JSON.stringify(name.includes(".") ? ext : "")}` };
17782
17803
  return { name };
17783
17804
  }
17784
17805
  var TAG2, attr, SRC_ATTR, LABEL_ATTR, SEGMENT2, storyboardTag, workflowTag;
@@ -17803,7 +17824,7 @@ var init_storyboard = __esm({
17803
17824
  var compare_default;
17804
17825
  var init_compare2 = __esm({
17805
17826
  "../artifact-sdk/src/builtin/compare.json"() {
17806
- compare_default = '{\n "name": "compare",\n "title": { "en": "Compare", "zh": "\u5BF9\u6BD4" },\n "types": ["compare"],\n "schema": {\n "type": "object",\n "required": ["a", "b"],\n "properties": { "a": { "type": "string" }, "b": { "type": "string" } }\n },\n "references": [\n { "json": "/a", "types": ["storyboard", "compare"] },\n { "json": "/b", "types": ["storyboard", "compare"] },\n { "json": "/shots", "types": ["storyboard", "compare"] }\n ]\n}\n';
17827
+ compare_default = '{\n "name": "compare",\n "title": { "en": "Compare", "zh": "\u5BF9\u6BD4" },\n "types": ["compare"],\n "schema": {\n "type": "object",\n "required": ["a", "b"],\n "properties": { "a": { "type": "string" }, "b": { "type": "string" } }\n },\n "references": [\n { "json": "/a", "types": ["storyboard", "compare", "spritesheet", "workflow"] },\n { "json": "/b", "types": ["storyboard", "compare", "spritesheet", "workflow"] },\n { "json": "/shots", "types": ["storyboard", "compare", "spritesheet", "workflow"] }\n ]\n}\n';
17807
17828
  }
17808
17829
  });
17809
17830
 
@@ -17864,7 +17885,7 @@ var init_spritesheet = __esm({
17864
17885
  var storyboard_default;
17865
17886
  var init_storyboard2 = __esm({
17866
17887
  "../artifact-sdk/src/builtin/storyboard.json"() {
17867
- storyboard_default = '{\n "name": "storyboard",\n "title": { "en": "Storyboard", "zh": "\u5206\u955C" },\n "types": ["storyboard"],\n "schema": {\n "type": "object",\n "anyOf": [{ "required": ["shots"] }, { "required": ["slides"] }],\n "properties": {\n "shots": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": { "frames": { "type": "array", "items": { "type": "object", "properties": { "src": { "type": "string" } } } } }\n }\n },\n "slides": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": {\n "preview": { "type": "object", "properties": { "src": { "type": "string" } } },\n "assets": { "type": "array", "items": { "type": "string" } }\n }\n }\n }\n }\n },\n "references": [\n { "json": "/shots/*/frames/*/src" },\n { "json": "/slides/*/preview/src" },\n { "json": "/slides/*/assets/*" }\n ]\n}\n';
17888
+ storyboard_default = '{\n "name": "storyboard",\n "title": { "en": "Storyboard", "zh": "\u5206\u955C" },\n "types": ["storyboard"],\n "schema": {\n "type": "object",\n "anyOf": [{ "required": ["shots"] }, { "required": ["slides"] }],\n "properties": {\n "shots": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": { "frames": { "type": "array", "items": { "type": "object", "properties": { "src": { "type": "string" } } } } }\n }\n },\n "slides": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": {\n "preview": { "type": "object", "properties": { "src": { "type": "string" } } },\n "assets": { "type": "array", "items": { "type": "string" } }\n }\n }\n }\n }\n },\n "references": [\n { "json": "/shots/*/frames/*/src", "types": ["storyboard", "compare", "spritesheet", "workflow"] },\n { "json": "/slides/*/preview/src", "types": ["storyboard", "compare", "spritesheet", "workflow"] },\n { "json": "/slides/*/assets/*" }\n ]\n}\n';
17868
17889
  }
17869
17890
  });
17870
17891
 
@@ -18083,7 +18104,7 @@ function bodyReferences(body) {
18083
18104
  for (const p2 of m[2].matchAll(/([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) a2[p2[1]] = p2[2] ?? p2[3];
18084
18105
  if (m[1] === "Compare") {
18085
18106
  if (!a2.a || !a2.b) continue;
18086
- for (const k2 of ["a", "b", "shots"]) if (a2[k2]) out.push({ src: a2[k2], types: COMPARE });
18107
+ for (const k2 of ["a", "b", "shots"]) if (a2[k2]) out.push({ src: a2[k2], types: ARRANGED });
18087
18108
  } else if (a2.src) {
18088
18109
  out.push({ src: a2.src, types: m[1] === "Storyboard" ? STORYBOARD : m[1] === "Workflow" ? WORKFLOW : m[1] === "Asset" ? ASSET : [] });
18089
18110
  if (a2.variants) {
@@ -18109,13 +18130,13 @@ function kindOf(ext) {
18109
18130
  if (type.startsWith("image/")) return "image";
18110
18131
  return type.startsWith("video/") || type.startsWith("audio/") ? "video" : "asset";
18111
18132
  }
18112
- var STORYBOARD, WORKFLOW, COMPARE, ASSET, isObject2, bodySources, TYPES;
18133
+ var STORYBOARD, WORKFLOW, ARRANGED, ASSET, isObject2, bodySources, TYPES;
18113
18134
  var init_references = __esm({
18114
18135
  "../artifact-sdk/src/internal/references.ts"() {
18115
18136
  "use strict";
18116
18137
  STORYBOARD = ["storyboard"];
18117
18138
  WORKFLOW = ["workflow"];
18118
- COMPARE = ["storyboard", "compare"];
18139
+ ARRANGED = ["storyboard", "compare", "spritesheet", "workflow"];
18119
18140
  ASSET = ["spritesheet", "asset"];
18120
18141
  isObject2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
18121
18142
  bodySources = (body) => [...new Set(bodyReferences(body).map((r2) => r2.src))];
@@ -18305,10 +18326,18 @@ function validatePreviewFiles(card, id, text5) {
18305
18326
  read: referenceText,
18306
18327
  retained: () => []
18307
18328
  });
18329
+ const kinds = new Map(graph.map((n) => [n.key, n.kind]));
18308
18330
  for (const node of graph) {
18309
18331
  for (const p2 of node.problems) {
18310
18332
  errors.push({ file: rel(node.file ?? card), line: p2.line ?? 1, rule: "preview-file", message: `${p2.at ? `${p2.at}: ` : ""}${p2.src}: ${p2.message}. Fix the reference or add the file.` });
18311
18333
  }
18334
+ if (node.kind !== "storyboard" && node.kind !== "compare") continue;
18335
+ for (const [src, key] of node.dependencies) {
18336
+ const kind = kinds.get(key);
18337
+ if (kind === "compare" || node.kind === "storyboard" && kind === "storyboard") {
18338
+ errors.push({ file: rel(node.file ?? card), line: 1, rule: "preview-nesting", message: `${src} is a ${kind}, which cannot go inside a ${node.kind}. Name its files directly.` });
18339
+ }
18340
+ }
18312
18341
  }
18313
18342
  return errors;
18314
18343
  }
@@ -18558,17 +18587,27 @@ function compareProblem(attrs, id) {
18558
18587
  const dir = path56.join(ASSETS, String(id));
18559
18588
  const src = (message) => ({ rule: "compare-src", message });
18560
18589
  const shots = (message) => ({ rule: "compare-shots", message });
18590
+ const json = (file) => {
18591
+ try {
18592
+ return file.endsWith(".json") ? JSON.parse(fs53.readFileSync(file, "utf8")) : null;
18593
+ } catch {
18594
+ return null;
18595
+ }
18596
+ };
18597
+ const files2 = {};
18561
18598
  for (const side of ["a", "b"]) {
18562
- const named2 = assetName(attrs[side], id, [...COMPARE_IMAGES, ...COMPARE_VIDEOS, ...side === "b" ? ["json"] : []]);
18599
+ const named2 = assetName(attrs[side], id, []);
18563
18600
  if (!("name" in named2)) return src(`Compare ${side} is ${named2.actual}; expected ${named2.expected}.`);
18564
- if (!inside(dir, named2.name)) return src(`Compare ${side} ${attrs[side]} names no file in this card's asset folder. Write the file there or fix the path.`);
18601
+ const file = inside(dir, named2.name);
18602
+ if (!file) return src(`Compare ${side} ${attrs[side]} names no file in this card's asset folder. Write the file there or fix the path.`);
18603
+ const data = files2[side] = json(file);
18604
+ if (typeof data?.a === "string" && typeof data.b === "string") return src(`Compare ${side} ${attrs[side]} is another compare. Compare its two files directly.`);
18565
18605
  }
18566
- const kind = compareKind(attrs.a);
18567
- const script = compareKind(attrs.b) === "storyboard";
18568
- if (script && kind !== "video") return src("Compare b may be a storyboard only when a is a video.");
18569
- if (!script && kind !== compareKind(attrs.b)) return src("Compare a and b must both be images or both be videos.");
18606
+ const video = compareKind(attrs.a) === "video";
18607
+ const board2 = files2.b;
18608
+ const script = video && Array.isArray(board2?.shots);
18570
18609
  if (attrs.shots === void 0) return script ? shots('shots is required when b is a storyboard. Add shots="..." naming a storyboard or shots list of video a.') : null;
18571
- if (kind !== "video") return shots("shots is for videos only. Remove it from this Compare tag.");
18610
+ if (!video || !(script || compareKind(attrs.b) === "video")) return shots("shots is for a video beside another video or its storyboard. Remove it from this Compare tag.");
18572
18611
  const read5 = (at2) => {
18573
18612
  const named2 = assetName(at2, id, ["json"]);
18574
18613
  if (!("name" in named2)) return { message: `Compare shots is ${named2.actual}; expected ${named2.expected}.` };
@@ -18585,12 +18624,10 @@ function compareProblem(attrs, id) {
18585
18624
  const why2 = Array.isArray(list.data) ? shotsProblem(list.data) : storyboardProblem(list.data);
18586
18625
  if (why2) return shots(`${attrs.shots}: ${why2}`);
18587
18626
  if (!script) return null;
18588
- const b2 = read5(attrs.b);
18589
- if ("message" in b2) return src(b2.message);
18590
- const bad = storyboardProblem(b2.data);
18627
+ const bad = storyboardProblem(board2);
18591
18628
  if (bad) return src(`${attrs.b}: ${bad}`);
18592
18629
  const known2 = new Set((Array.isArray(list.data) ? list.data : list.data.shots).map((s) => s.id));
18593
- const extra = b2.data.shots.find((s) => !known2.has(s.id));
18630
+ const extra = board2.shots.find((s) => !known2.has(s.id));
18594
18631
  return extra ? shots(`${attrs.b} has shot ${extra.id}, which ${attrs.shots} lacks. Add ${extra.id} to ${attrs.shots}, or drop it from ${attrs.b}.`) : null;
18595
18632
  }
18596
18633
  function validateStoryboards(file, id, text5) {
@@ -18658,6 +18695,7 @@ function validateHumanSection(file, text5, { agent }) {
18658
18695
  if (heading > markers[0]) return [{ ...where, line: heading, message: `Move ## ${title} above <!-- agent -->: the \`${agent}\` agent's output is for the user to review.` }];
18659
18696
  return [];
18660
18697
  }
18698
+ var formatProblems;
18661
18699
  var init_spec_contract = __esm({
18662
18700
  "src/lib/spec-contract.ts"() {
18663
18701
  "use strict";
@@ -18668,6 +18706,7 @@ var init_spec_contract = __esm({
18668
18706
  init_storyboard();
18669
18707
  init_preview_files();
18670
18708
  init_validate();
18709
+ formatProblems = (errors) => ["Task format problems:", ...errors.map((e2) => `- ${e2.message}`)].join("\n");
18671
18710
  }
18672
18711
  });
18673
18712
 
@@ -21922,7 +21961,15 @@ var init_board3 = __esm({
21922
21961
  var card_chat_default;
21923
21962
  var init_card_chat = __esm({
21924
21963
  "src/guide/card-chat.md"() {
21925
- card_chat_default = "# Answer a card's conversation\n\nWork on the current card and its assets by default. Project implementation requires approval on the review page.\n\n- **Change requirements or drafts**: when the user changes the scope, expected behavior, or draft, use `akb card revise <id> --print \"<change>\"`.\n- **Record an answer**: when the user answers an open question on the card, use `akb card resolve <id> --print`.\n- **Manage open questions**: when a decision needs the user's input, follow `akb guide update-questions` and use `akb raw update-questions <id>` to edit the question list.\n- **Change card fields**: when the user changes metadata such as priority, modules, or dependencies, use `akb raw update <id>`.\n- **Choose a preview agent**: when a preview is needed and the agent is unclear, use `akb previews --triggers` to match the work to an agent.\n- **Create or revise a preview**: when the user asks to see or change a preview for the current card, use `akb previews <agent> <id> --print`.\n- **Create a separate task**: when the user asks to capture work unrelated to this card, follow `akb guide add-task`.\n- **Split this card**: when the user asks to break this card's outcome into subtasks, follow the group procedure in `akb guide add-task`.\n- **Check card edits**: after writing a card, run `akb raw validate <id>` and fix what it reports.\n- **Look up syntax**: when you need flags or argument details, use the command's `--help` or `akb help`.\n\nReply in plain, natural language. Do not write memory, including through any flow this conversation starts.\n";
21964
+ card_chat_default = "# Answer a card's conversation\n\nWork on the current card and its assets by default. Project implementation requires approval on the review page.\n\n- **Change requirements or drafts**: when the user changes the scope, expected behavior, or draft, use `akb card revise <id> --print \"<change>\"`.\n- **Record an answer**: when the user answers an open question on the card, use `akb card resolve <id> --print`.\n- **Manage open questions**: when a decision needs the user's input, follow `akb guide update-questions` and use `akb raw update-questions <id>` to edit the question list.\n- **Change card fields**: when the user changes metadata such as priority, modules, or dependencies, use `akb raw update <id>`.\n- **Choose a preview agent**: when a preview is needed and the agent is unclear, use `akb previews --triggers` to match the work to an agent.\n- **Create or revise a preview**: when the user asks to see or change a preview for the current card, use `akb previews <agent> <id> --print`.\n- **Create a separate task**: when the user asks to capture work unrelated to this card, follow `akb guide add-task`.\n- **Split this card**: when the user asks to break this card's outcome into subtasks, follow the group procedure in `akb guide add-task`.\n- **Change a workflow**: when the user asks to change a workflow or one of its agents, follow `akb guide update-workflow`.\n- **Check card edits**: after writing a card, run `akb raw validate <id>` and fix what it reports.\n- **Look up syntax**: when you need flags or argument details, use the command's `--help` or `akb help`.\n\nReply in plain, natural language. Do not write memory, including through any flow this conversation starts.\n";
21965
+ }
21966
+ });
21967
+
21968
+ // src/guide/update-workflow.md
21969
+ var update_workflow_default;
21970
+ var init_update_workflow = __esm({
21971
+ "src/guide/update-workflow.md"() {
21972
+ update_workflow_default = "# Update a workflow\n\nChange one of this workspace's workflows so new tasks run the new version.\n\n## How a workflow works\n\nA workflow is steerable: agents do the work, and a person reviews and fine-tunes only the parts where precision matters most, so the result stays reliable.\n\n- **Previews**: give a part its own preview agent only when it needs precision and a mistake there is costly, such as a developer tool's screens, whose experience drives retention. Each shows only what the person decides on, without overlapping another.\n- **Stages**: previews are approved together in one stage by default. Add `after` only when a draft is too costly to make before another is approved, such as a video's storyboard, which waits for its script.\n- **Land**: everything else runs unattended after the last approval and follows the approved drafts, such as building and merging a change; leave `land` empty when the last approved preview is the deliverable.\n- **Scheduled**: repeating work runs as a scheduled agent without previews; a workflow may hold only scheduled agents.\n- **`WORKFLOW.md`**: list its agents under `previews`, `land` and `scheduled`; `description` says in one sentence what it does; `when` tells an agent which requests it is for, exceptions included; the body is how a card of this kind is written.\n- **Agents**: write each as `akb guide write-agent` says.\n\n## Versions\n\n- **Pinned**: a workflow and the agents it holds live in Cloud as numbered versions; a task\n keeps the version it started with, and only tasks started after a push take the new one.\n- **Project agents**: agents under the board's `agents/` folder are the project's own; a\n workflow may name them, but they are not part of its versions and an edit there applies to\n every card at once.\n- **Own workflows only**: built-in and marketplace workflows are read-only; ask the user to copy\n one on the web first.\n\n## Change it\n\n- **Direct or task**: push directly a change the user spelled out; start a Workflow builder task\n instead when the change adds, removes or restages agents, or when the user wants to see it\n work before it applies.\n- **Steps**: `akb workflow pull <id> <folder>`, edit the files there and keep what the request\n leaves alone, fix every problem `akb workflow list` reports, then `akb workflow push <folder>`.\n- **Moved on**: when push says Cloud has a newer version, pull again and redo the change.\n";
21926
21973
  }
21927
21974
  });
21928
21975
 
@@ -22092,6 +22139,7 @@ var init_guide = __esm({
22092
22139
  init_archive2();
22093
22140
  init_board3();
22094
22141
  init_card_chat();
22142
+ init_update_workflow();
22095
22143
  init_describe_project();
22096
22144
  init_discuss_goal();
22097
22145
  init_follow_up();
@@ -22118,6 +22166,7 @@ var init_guide = __esm({
22118
22166
  { name: "discuss-goal", when: "help decide what is worth building, and shape it into goals to start as tasks", text: discuss_goal_default },
22119
22167
  { name: "troubleshoot", when: "\u5B9A\u4F4D\u8F6F\u4EF6\u6545\u969C\u7684\u6839\u56E0\u4E0E\u4FEE\u590D\u65B9\u5411", text: troubleshoot_default },
22120
22168
  { name: "card-chat", when: "answer a card's conversation, and act on what each turn settles", text: card_chat_default },
22169
+ { name: "update-workflow", when: "change one of this workspace's workflows so new tasks run the new version", text: update_workflow_default },
22121
22170
  { name: "implement", when: "build a settled card and stop cleanly on an execution blocker", text: implement_default },
22122
22171
  { name: "archive", when: "finish a task \u2014 write its shipped line, then take it off the board", text: archive_default },
22123
22172
  { name: "update-questions", when: "decide what to ask the user, and write the question", text: update_questions_default },
@@ -107661,18 +107710,18 @@ function backoffMs(attempt2, random = Math.random) {
107661
107710
  const step = Math.min(CAP_MS, BASE_MS * 2 ** Math.max(0, attempt2 - 2));
107662
107711
  return Math.round(step * (1 - JITTER * random()));
107663
107712
  }
107664
- function planRetry2(prev, failure, startedAt, now = Date.now(), random = Math.random) {
107713
+ function planRetry2(prev, failure, startedAt, now = Date.now(), random = Math.random, windowed = true) {
107665
107714
  const attempt2 = (prev?.attempt ?? 1) + 1;
107666
107715
  if (attempt2 > RETRY_ATTEMPTS) return null;
107667
107716
  const since = prev?.since ?? startedAt;
107668
107717
  const wait = failure.retryAfterMs ?? backoffMs(attempt2, random);
107669
107718
  const at2 = now + wait;
107670
- if (at2 > since + RETRY_WINDOW_MS) return null;
107719
+ if (windowed && at2 > since + RETRY_WINDOW_MS) return null;
107671
107720
  return { attempt: attempt2, of: RETRY_ATTEMPTS, reason: failure.reason, at: at2, since };
107672
107721
  }
107673
107722
  function retryLine(retry2, now = Date.now()) {
107674
107723
  const seconds = Math.max(1, Math.round((retry2.at - now) / 1e3));
107675
- return `${retry2.reason} \u2014 the provider failed for a moment, so this run tries again in ${seconds}s (attempt ${retry2.attempt} of ${retry2.of}).`;
107724
+ return `${retry2.reason} \u2014 this run tries again in ${seconds}s (attempt ${retry2.attempt} of ${retry2.of}).`;
107676
107725
  }
107677
107726
  var RETRY_ATTEMPTS, RETRY_WINDOW_MS, BASE_MS, CAP_MS, JITTER;
107678
107727
  var init_retry = __esm({
@@ -107927,8 +107976,9 @@ async function watchRun(sessionId, resume = startResume) {
107927
107976
  const ours = asked || silent || !!blocker;
107928
107977
  const said3 = failure ?? spoken?.error;
107929
107978
  const offStream = renderer?.offStream?.();
107930
- const blip = ours || sub || code === 0 && !said3 || !resumeSessionId(held4) ? void 0 : active2.transient?.({ failure: said3, result, offStream });
107931
- const again = blip ? planRetry2(held4.retry, blip, held4.startedAt) : null;
107979
+ const quiet = silent && !asked && !blocker && !sub && !!resumeSessionId(held4);
107980
+ const blip = quiet ? { reason: waited ? backgroundSaid(BACKGROUND_WAIT.minutes) : silenceSaid(silenceFor) } : ours || sub || code === 0 && !said3 || !resumeSessionId(held4) ? void 0 : active2.transient?.({ failure: said3, result, offStream });
107981
+ const again = blip ? planRetry2(held4.retry, blip, held4.startedAt, Date.now(), Math.random, !quiet) : null;
107932
107982
  if (again) {
107933
107983
  log.write(`
107934
107984
  [board] ${retryLine(again)}
@@ -107955,6 +108005,7 @@ async function watchRun(sessionId, resume = startResume) {
107955
108005
  const required = new Set(record.formatRepair?.cardIds ?? []);
107956
108006
  const heldElsewhere = withStore((store) => new Set(store.runs.filter((r2) => r2.sessionId !== sessionId && r2.status === "running" && holdsCard(r2.action)).flatMap((r2) => [r2.cardId, ...r2.createdCardIds ?? []]).filter((id) => id !== null)));
107957
108007
  let formatErrors = [];
108008
+ let broken = [];
107958
108009
  if (!sub) {
107959
108010
  try {
107960
108011
  const discarded = new Set(cleanupDiscardedCards(sessionId));
@@ -107997,6 +108048,11 @@ async function watchRun(sessionId, resume = startResume) {
107997
108048
  required.add(record.cardId);
107998
108049
  formatErrors.push({ file: rel(TODO), line: 1, rule: "missing-card", message: `Task #${record.cardId} disappeared. Restore its card file; this run must not delete it.` });
107999
108050
  }
108051
+ if (repairable) {
108052
+ const owed = new Set(record.formatRepair?.broken ?? []);
108053
+ broken = boardComplaints().filter((line) => owed.has(line) || !wasBroken.has(line));
108054
+ formatErrors.push(...broken.map((line) => ({ file: rel(TODO), line: 1, rule: "board-broken", message: `${line} Take a card off the board with \`${boardCommand()} raw archive <id>\` or \`${boardCommand()} raw reject <id>\`, never by deleting its file.` })));
108055
+ }
108000
108056
  for (const id of departed) log.write(`
108001
108057
  [board] Task #${id} left the board with its landing; there is nothing to restore.
108002
108058
  `);
@@ -108008,6 +108064,7 @@ async function watchRun(sessionId, resume = startResume) {
108008
108064
  }
108009
108065
  }
108010
108066
  const contractError = formatErrors.length ? formatContractErrors(formatErrors) : void 0;
108067
+ const problems = formatErrors.length ? formatProblems(formatErrors) : void 0;
108011
108068
  if (contractError) {
108012
108069
  log.write(`
108013
108070
  [validation] ${contractError}
@@ -108021,6 +108078,7 @@ async function watchRun(sessionId, resume = startResume) {
108021
108078
  r2.formatRepair = contractError ? {
108022
108079
  attempt: record.formatRepair?.attempt ?? 0,
108023
108080
  errors: contractError,
108081
+ ...broken.length ? { broken } : {},
108024
108082
  cardIds: [...required],
108025
108083
  changedIds: changed,
108026
108084
  existingIds: [...original.keys()]
@@ -108044,12 +108102,8 @@ ${result}
108044
108102
  if (result) r2.result = result;
108045
108103
  });
108046
108104
  const settled = status === "done" && !sub ? settleBoard(record, changed, original) : null;
108047
- const broke = status === "done" && !sub ? brokeBoard(wasBroken) : null;
108048
- const note = status === "done" ? joinNotes(settled?.stalled, broke?.note) : void 0;
108049
- const noteWhy = [
108050
- ...status === "done" ? settled?.stalledWhy ?? [] : [],
108051
- ...broke ? [broke.why] : []
108052
- ];
108105
+ const note = status === "done" ? settled?.stalled : void 0;
108106
+ const noteWhy = status === "done" ? settled?.stalledWhy ?? [] : [];
108053
108107
  const saidOurs = !asked && silent && !spawnError;
108054
108108
  const errorWhy = [
108055
108109
  ...contractError ? [{ kind: "format" }] : [],
@@ -108080,7 +108134,7 @@ ${result}
108080
108134
  // stream said so. That cause leads; a card it left half-written follows.
108081
108135
  error: joinNotes(
108082
108136
  spawnError ?? (asked ? void 0 : silent ? quietSaid : spoken?.error ?? failure),
108083
- contractError
108137
+ problems
108084
108138
  ),
108085
108139
  note,
108086
108140
  errorWhy,
@@ -108091,7 +108145,7 @@ ${result}
108091
108145
  if (contractError && repairable && (record.formatRepair?.attempt ?? 0) < MAX_FORMAT_REPAIRS) {
108092
108146
  const next = await resume(sessionId);
108093
108147
  if ("error" in next) patch(sessionId, (r2) => {
108094
- r2.error = `${contractError}
108148
+ r2.error = `${problems}
108095
108149
  Cannot resume format repair: ${next.error}`;
108096
108150
  r2.errorWhy = [{ kind: "format" }, { kind: "repairUnstarted", refusals: [next] }];
108097
108151
  });
@@ -108199,19 +108253,6 @@ Cannot resume format repair: ${next.error}`;
108199
108253
  child.on("close", (code) => void finish(code, peekRun(sessionId)?.stopping === true || stopped2));
108200
108254
  });
108201
108255
  }
108202
- function brokeBoard(wasBroken) {
108203
- const broke = boardComplaints().filter((line) => !wasBroken.has(line));
108204
- if (!broke.length) return null;
108205
- const shown = broke.slice(0, MAX_BROKEN);
108206
- const rest = broke.length - shown.length;
108207
- const why2 = { kind: "broken", args: { n: String(broke.length), more: String(rest) }, lines: shown };
108208
- return { why: why2, note: [
108209
- `the work is done, but the board came out of this run inconsistent \u2014 ${broke.length} thing${broke.length === 1 ? "" : "s"} to put right:`,
108210
- ...shown.map((line) => ` ${line}`),
108211
- ...rest ? [` \u2026 and ${rest} more`] : [],
108212
- `a card is taken off the board with \`${boardCommand()} raw archive <id>\` or \`${boardCommand()} raw reject <id>\`, never by deleting its file.`
108213
- ].join("\n") };
108214
- }
108215
108256
  function settleBoard(run3, changed, before) {
108216
108257
  try {
108217
108258
  const helpers = specRunsAfter(readSpecAsks(run3.sessionId));
@@ -108276,7 +108317,7 @@ function catchModel(sessionId, model) {
108276
108317
  });
108277
108318
  return true;
108278
108319
  }
108279
- var STOP_GRACE_MS, STOP_CLOSE_MS, STOP_FINISH_MS, silenceSaid, backgroundSaid, MAX_FORMAT_REPAIRS, MAX_BROKEN, joinNotes;
108320
+ var STOP_GRACE_MS, STOP_CLOSE_MS, STOP_FINISH_MS, silenceSaid, backgroundSaid, MAX_FORMAT_REPAIRS, joinNotes;
108280
108321
  var init_watch = __esm({
108281
108322
  "src/lib/agent/watch.ts"() {
108282
108323
  "use strict";
@@ -108312,7 +108353,6 @@ var init_watch = __esm({
108312
108353
  silenceSaid = (minutes) => `the agent said nothing for ${minutes} minute${minutes === 1 ? "" : "s"}, so the run was ended.`;
108313
108354
  backgroundSaid = (minutes) => `the agent's background tasks did not finish within ${minutes / 60} hours, so the run was ended.`;
108314
108355
  MAX_FORMAT_REPAIRS = 3;
108315
- MAX_BROKEN = 5;
108316
108356
  joinNotes = (...parts) => parts.filter(Boolean).join("\n\n") || void 0;
108317
108357
  }
108318
108358
  });
@@ -110042,8 +110082,8 @@ init_cloud_workflows();
110042
110082
  init_workflows();
110043
110083
  init_workflow_folder();
110044
110084
  init_workflow_files();
110045
- init_config();
110046
- init_session();
110085
+ init_board_files();
110086
+ init_tasks();
110047
110087
  import fs77 from "node:fs";
110048
110088
  import path78 from "node:path";
110049
110089
  var found = (id) => {
@@ -110109,37 +110149,64 @@ function cmdWorkflowDiagram(id, card) {
110109
110149
  say(tag);
110110
110150
  return { file, tag, diagram };
110111
110151
  }
110112
- var PUBLISH_REFUSED = {
110113
- not_creator: "only accounts WildCrane has made creators can publish to the marketplace",
110114
- not_yours: "another creator holds this name, or it is a built-in"
110115
- };
110116
- async function cmdWorkflowPublish(folder, opts) {
110152
+ var PULLED = ".akb-workflow.json";
110153
+ var cloudIdOf = (id) => cloudFlows().find((f2) => workflowName(f2.cloudId) === id)?.cloudId;
110154
+ async function cmdWorkflowPull(id, folder) {
110155
+ const cloudId = cloudIdOf(id);
110156
+ if (!cloudId) found(id);
110157
+ const dir = path78.resolve(folder ?? id);
110158
+ if (fs77.existsSync(dir) && fs77.readdirSync(dir).length) die(`${folder ?? id} is not empty`, "bad-args");
110159
+ const read5 = await call("GET", `/v1/workflows/${encodeURIComponent(cloudId)}`);
110160
+ if (!read5.ok) die(read5.error, read5.code === "not_found" ? "no-such-workflow" : "cloud-refused");
110161
+ const { version, files: files2 } = read5.value;
110162
+ for (const [file, text5] of Object.entries(files2)) {
110163
+ const full = path78.join(dir, ...file.split("/"));
110164
+ fs77.mkdirSync(path78.dirname(full), { recursive: true });
110165
+ const data = isAboutFile(file) && !file.endsWith(".md") && /^data:[^;]+;base64,/.exec(text5);
110166
+ fs77.writeFileSync(full, data ? Buffer.from(text5.slice(data[0].length), "base64") : text5);
110167
+ }
110168
+ fs77.writeFileSync(path78.join(dir, PULLED), `${JSON.stringify({ id: cloudId, version })}
110169
+ `);
110170
+ const shown = folder ?? `./${id}`;
110171
+ say(`Pulled ${id} v${version} into ${shown}.`);
110172
+ return { id, version, folder: dir };
110173
+ }
110174
+ async function cmdWorkflowPush(folder, opts) {
110117
110175
  const dir = path78.resolve(folder);
110118
- if (!fs77.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder} is not a folder`, "bad-args");
110119
- const slug2 = path78.basename(dir);
110120
- const files2 = readWorkflowFolder(dir);
110121
- const checked = checkWorkflowFiles(files2, true);
110122
- if (!checked.ok) die(`${slug2}: ${checked.file} ${checked.reason}`, "bad-workflow");
110123
- const token3 = await accessToken();
110124
- if (!token3.ok) die(SAID[token3.reason].en, "cloud-refused");
110125
- let res;
110176
+ let pulled = null;
110126
110177
  try {
110127
- res = await fetch(`${cloudEndpoints().api}/v1/marketplace/workflows`, {
110128
- method: "POST",
110129
- headers: { authorization: `Bearer ${token3.token}`, "content-type": "application/json" },
110130
- body: JSON.stringify({ slug: slug2, files: files2, ...opts.dryRun ? { dry_run: true } : {} })
110131
- });
110178
+ pulled = JSON.parse(fs77.readFileSync(path78.join(dir, PULLED), "utf8"));
110132
110179
  } catch {
110133
- die(SAID.unreachable.en, "cloud-refused");
110134
110180
  }
110135
- const body = await res.json().catch(() => ({}));
110181
+ if (!pulled?.id || !Number.isInteger(pulled.version)) die(`${folder} was not written by \`akb workflow pull\``, "bad-args");
110182
+ const { id: cloudId, version } = pulled;
110183
+ const id = workflowName(cloudId);
110184
+ const readOnly2 = () => die(`${id} is not this workspace's own; copy it on the web first.`, "workflow-read-only");
110185
+ if (cloudId.startsWith("wf_builtin_")) readOnly2();
110186
+ const files2 = readWorkflowFolder(dir);
110187
+ const checked = checkWorkflowFiles(files2);
110188
+ if (!checked.ok) die(`${checked.file} ${checked.reason}`, "bad-workflow");
110189
+ const now = await call("GET", `/v1/workflows/${encodeURIComponent(cloudId)}`);
110190
+ if (!now.ok) die(now.error, now.code === "not_found" ? "no-such-workflow" : "cloud-refused");
110191
+ if (now.value.version !== version) die(`${id} is at v${now.value.version} now; pull again and redo the change.`, "workflow-moved");
110192
+ if (JSON.stringify(files2) === JSON.stringify(Object.fromEntries(Object.entries(now.value.files).sort()))) {
110193
+ say(`${id} is unchanged (v${version}).`);
110194
+ return { id, version, changed: false, ...opts.dryRun ? { dryRun: true } : {} };
110195
+ }
110196
+ if (opts.dryRun) {
110197
+ say(`${id} would push v${version + 1}.`);
110198
+ return { id, version: version + 1, changed: true, dryRun: true };
110199
+ }
110200
+ const res = await call("PATCH", `/v1/workflows/${encodeURIComponent(cloudId)}`, { files: files2 });
110136
110201
  if (!res.ok) {
110137
- if (res.status === 401) die(SAID.expired.en, "cloud-refused");
110138
- const code = body.error?.code ?? "failed";
110139
- die(`${slug2}: ${PUBLISH_REFUSED[code] ?? body.error?.message ?? `Cloud answered ${res.status}`}`, code);
110202
+ if (res.code === "read_only" || res.code === "not_found") readOnly2();
110203
+ die(res.error, res.code === "bad_request" || res.code === "payload_too_large" ? "bad-workflow" : "cloud-refused");
110140
110204
  }
110141
- say(!body.changed ? `${slug2} is unchanged (v${body.version}).` : opts.dryRun ? `${slug2} would publish v${body.version}.` : `Published ${slug2} v${body.version}.`);
110142
- return { slug: slug2, id: body.id, version: body.version, changed: body.changed, ...opts.dryRun ? { dryRun: true } : {} };
110205
+ const next = res.value.version;
110206
+ fs77.writeFileSync(path78.join(dir, PULLED), `${JSON.stringify({ id: cloudId, version: next })}
110207
+ `);
110208
+ say(`Pushed ${id} v${next}. New tasks take it.`);
110209
+ return { id, version: next, changed: true };
110143
110210
  }
110144
110211
 
110145
110212
  // src/commands/run.ts
@@ -111392,7 +111459,7 @@ List trigger conditions: ${cli.program} previews --triggers --json`).action(asyn
111392
111459
  });
111393
111460
  }
111394
111461
  const workflow = withShared(program2.command("workflow")).summary("the workflows this board runs, and the agents each one lists").description(
111395
- "Every card runs through one workflow, kept in Cloud: the built-ins and the workflows this workspace installed or made. A card runs on the version its task started with; a new task takes the latest. Edit workflows on the web."
111462
+ "Every card runs through one workflow, kept in Cloud: the built-ins and the workflows this workspace installed or made. To change one of this workspace's own: `pull` it into a folder, edit, `push`. New tasks take the new version; a task already started keeps its own. `akb guide update-workflow` has the whole flow."
111396
111463
  ).allowExcessArguments().allowUnknownOption().action(async function() {
111397
111464
  if (this.args.length) this.error(`unknown command '${this.args[0]}'`, { code: "commander.unknownCommand" });
111398
111465
  await workflowList(this, cli);
@@ -111407,8 +111474,11 @@ List trigger conditions: ${cli.program} previews --triggers --json`).action(asyn
111407
111474
  flowWord("diagram").argument("<id>", "the workflow, from `workflow list`").argument("<card>", "the card whose asset folder gets workflow.json").summary("write the workflow's diagram to .assets/<card>/workflow.json and print the <Workflow> tag that shows it").action(async function(id, card) {
111408
111475
  await onBoard2(this, cli, () => cmdWorkflowDiagram(id, card));
111409
111476
  });
111410
- flowWord("publish").argument("<folder>", "the workflow folder; its name is the slug").option("--dry-run", "check the folder and print what would happen, publishing nothing").summary("publish a workflow folder to the marketplace as the signed-in account. Prints the version new tasks take, or that nothing changed.").action(async function(folder) {
111411
- await boardless(this, cli, () => cmdWorkflowPublish(folder, this.opts()));
111477
+ flowWord("pull").argument("<id>", "the workflow, from `workflow list`").argument("[folder]", "where to write it, empty or new; default ./<id>").summary("write the workflow's current version into a folder to edit").action(async function(id, folder) {
111478
+ await onBoard2(this, cli, () => cmdWorkflowPull(id, folder));
111479
+ });
111480
+ flowWord("push").argument("<folder>", "a folder `workflow pull` wrote").option("--dry-run", "check the folder and print what would happen, saving nothing").summary("save the edited folder as the workflow's next version, which new tasks take").action(async function(folder) {
111481
+ await boardless(this, cli, () => cmdWorkflowPush(folder, this.opts()));
111412
111482
  });
111413
111483
  withShared(program2.command("components")).summary("list an agent or workflow\u2019s preview components and their usage").option("--agent <name>", "one agent\u2019s components").option("--workflow <id>", "all components used by a workflow").option("--docs", "include component usage documentation").action(async function() {
111414
111484
  const ctx = ctxOf(this, cli.program);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wildcrane",
3
- "version": "0.11.30",
3
+ "version": "0.11.31",
4
4
  "akbContract": 7,
5
5
  "description": "WildCrane's `akb` command — scaffold the Markdown board under docs/kanban/, put an agent on a card, and carry the flows the agent works by.",
6
6
  "keywords": [
@@ -13,7 +13,7 @@
13
13
  "markdown",
14
14
  "board"
15
15
  ],
16
- "license": "FSL-1.1-ALv2",
16
+ "license": "Apache-2.0",
17
17
  "homepage": "https://wildcrane.ai/",
18
18
  "repository": {
19
19
  "type": "git",