@mmerterden/multi-agent-pipeline 23.7.0 → 24.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -1
- package/README.md +59 -24
- package/README.tr.md +43 -8
- package/SECURITY.md +3 -3
- package/docs/architecture.md +41 -4
- package/docs/ecosystem.md +15 -13
- package/docs/facts.json +5 -4
- package/docs/features.md +67 -15
- package/install/_codex-agents.mjs +13 -8
- package/install/_common.mjs +24 -0
- package/install/_dev-only-files.mjs +5 -0
- package/install/_mcp-register.mjs +6 -2
- package/install/_rewrite-tree.mjs +197 -0
- package/install/codex.mjs +96 -180
- package/install/copilot.mjs +24 -54
- package/install/index.mjs +29 -11
- package/install/templates/codex-instructions.md +21 -5
- package/install/templates/copilot-instructions.md +21 -14
- package/manifest.json +2083 -0
- package/package.json +8 -2
- package/pipeline/commands/multi-agent/SKILL.md +5 -4
- package/pipeline/commands/multi-agent/analysis/SKILL.md +5 -1
- package/pipeline/commands/multi-agent/autopilot-on/SKILL.md +31 -3
- package/pipeline/commands/multi-agent/autopilot-status/SKILL.md +5 -1
- package/pipeline/commands/multi-agent/channels/SKILL.md +16 -8
- package/pipeline/commands/multi-agent/log/SKILL.md +2 -0
- package/pipeline/commands/multi-agent/stack/SKILL.md +1 -1
- package/pipeline/contract/CHANGELOG.md +15 -0
- package/pipeline/contract/fixtures/error-invalid-request.json +1 -1
- package/pipeline/contract/fixtures/error-unauthorized.json +1 -1
- package/pipeline/contract/fixtures/runs-awaiting-question.json +6 -1
- package/pipeline/contract/fixtures/runs-empty.json +1 -1
- package/pipeline/contract/fixtures/runs-failed.json +21 -1
- package/pipeline/contract/fixtures/runs-old-schema.json +18 -3
- package/pipeline/contract/fixtures/runs-pr-opened-redacted.json +31 -1
- package/pipeline/contract/fixtures/runs-pr-opened.json +31 -1
- package/pipeline/contract/fixtures/runs-running.json +16 -1
- package/pipeline/contract/manifest.json +14 -14
- package/pipeline/contract/types/index.d.ts +20 -1
- package/pipeline/lib/_jira-auth.sh +50 -78
- package/pipeline/lib/_service-account.sh +191 -0
- package/pipeline/lib/credential-inventory.sh +49 -37
- package/pipeline/lib/credential-store.sh +48 -3
- package/pipeline/lib/fetch-confluence.sh +76 -92
- package/pipeline/lib/fetch-crashlytics.sh +30 -59
- package/pipeline/lib/fetch-figma-annotations.sh +9 -9
- package/pipeline/lib/fetch-fortify.sh +77 -81
- package/pipeline/lib/fetch-graylog.sh +38 -77
- package/pipeline/lib/figma-mcp-refresh.sh +23 -4
- package/pipeline/lib/figma-screenshot.sh +7 -8
- package/pipeline/lib/figma-token.sh +39 -46
- package/pipeline/lib/host.mjs +138 -0
- package/pipeline/lib/host.sh +48 -0
- package/pipeline/lib/issue-fetcher.sh +25 -41
- package/pipeline/lib/jira-publish.sh +23 -21
- package/pipeline/lib/local-model.mjs +93 -0
- package/pipeline/lib/md2confluence-v3.py +37 -30
- package/pipeline/lib/model-dispatch.sh +41 -4
- package/pipeline/lib/model-resolve.mjs +58 -0
- package/pipeline/lib/post-pr-review.sh +38 -53
- package/pipeline/lib/reviewer-families.mjs +70 -0
- package/pipeline/lib/service-account.mjs +2131 -0
- package/pipeline/lib/service-account.sh +35 -0
- package/pipeline/lib/usage-token.mjs +64 -24
- package/pipeline/lib/usage-vocab.mjs +1 -1
- package/pipeline/lib/user-facing.mjs +11 -3
- package/pipeline/lib/vercel-deploy.sh +17 -26
- package/pipeline/multi-agent-refs/_entry-picker.md +62 -0
- package/pipeline/multi-agent-refs/analysis/intake.md +2 -0
- package/pipeline/multi-agent-refs/analysis/render.md +12 -1
- package/pipeline/multi-agent-refs/analysis/reusable-refs.md +1 -0
- package/pipeline/multi-agent-refs/analysis/unattended.md +135 -0
- package/pipeline/multi-agent-refs/autopilot-on/details.md +16 -0
- package/pipeline/multi-agent-refs/channels/generator.md +10 -2
- package/pipeline/multi-agent-refs/channels/menu.md +3 -1
- package/pipeline/multi-agent-refs/channels/preview.md +3 -1
- package/pipeline/multi-agent-refs/channels/reference.md +16 -2
- package/pipeline/multi-agent-refs/channels/report-file.md +188 -0
- package/pipeline/multi-agent-refs/cross-cli-contract.md +35 -27
- package/pipeline/multi-agent-refs/features/doctor.md +37 -11
- package/pipeline/multi-agent-refs/features/free-models.md +3 -3
- package/pipeline/multi-agent-refs/features/local-model.md +87 -0
- package/pipeline/multi-agent-refs/features/model-fallback.md +25 -10
- package/pipeline/multi-agent-refs/features/product-context.md +6 -5
- package/pipeline/multi-agent-refs/features/service-accounts.md +233 -0
- package/pipeline/multi-agent-refs/features/unattended-security.md +10 -1
- package/pipeline/multi-agent-refs/help/en.md +36 -1
- package/pipeline/multi-agent-refs/help/tr.md +34 -1
- package/pipeline/multi-agent-refs/orchestrator/copilot-pipeline.md +2 -1
- package/pipeline/multi-agent-refs/orchestrator/dispatcher.md +2 -1
- package/pipeline/multi-agent-refs/phases/modes.md +20 -1
- package/pipeline/multi-agent-refs/phases/phase-0-init.md +1 -0
- package/pipeline/multi-agent-refs/phases/phase-4-commit.md +1 -0
- package/pipeline/multi-agent-refs/phases/phase-5-report.md +13 -11
- package/pipeline/multi-agent-refs/phases.md +4 -3
- package/pipeline/multi-agent-refs/review/panel.md +30 -18
- package/pipeline/multi-agent-refs/setup/discovery.md +17 -5
- package/pipeline/multi-agent-refs/setup/token-save-flow.md +21 -2
- package/pipeline/multi-agent-refs/sync/overview.md +11 -5
- package/pipeline/multi-agent-refs/tracker-contract.md +64 -20
- package/pipeline/office/index.html +77 -4
- package/pipeline/schemas/activity.schema.json +63 -4
- package/pipeline/schemas/autopilot-config.schema.json +29 -4
- package/pipeline/schemas/hosts.json +512 -0
- package/pipeline/schemas/hosts.schema.json +310 -0
- package/pipeline/schemas/launch.json +22 -2
- package/pipeline/schemas/launch.schema.json +2 -1
- package/pipeline/schemas/now-lines.json +103 -0
- package/pipeline/schemas/now-lines.schema.json +42 -0
- package/pipeline/schemas/phases.json +19 -1
- package/pipeline/schemas/phases.schema.json +8 -0
- package/pipeline/schemas/prefs.schema.json +331 -4
- package/pipeline/schemas/runs-index.schema.json +22 -1
- package/pipeline/scripts/_autopilot-config.mjs +67 -4
- package/pipeline/scripts/_autopilot-item.mjs +67 -0
- package/pipeline/scripts/_autopilot-outcomes.mjs +6 -0
- package/pipeline/scripts/_contract-core.mjs +1 -1
- package/pipeline/scripts/_cost.mjs +75 -3
- package/pipeline/scripts/activity-snapshot.mjs +27 -1
- package/pipeline/scripts/analysis-sources.mjs +22 -5
- package/pipeline/scripts/analysis-unattended.mjs +360 -0
- package/pipeline/scripts/anonymize-findings.mjs +3 -7
- package/pipeline/scripts/autopilot-arming.mjs +19 -10
- package/pipeline/scripts/autopilot-intake.mjs +124 -27
- package/pipeline/scripts/autopilot-menubar.swift +7 -0
- package/pipeline/scripts/autopilot-runner.mjs +77 -48
- package/pipeline/scripts/autopilot-status.sh +32 -9
- package/pipeline/scripts/bulk-read.sh +37 -5
- package/pipeline/scripts/confluence-readback.mjs +15 -7
- package/pipeline/scripts/cost-table.json +65 -25
- package/pipeline/scripts/doctor.mjs +119 -32
- package/pipeline/scripts/entry-mode.mjs +101 -0
- package/pipeline/scripts/estimate.mjs +30 -16
- package/pipeline/scripts/feedback-send.mjs +11 -8
- package/pipeline/scripts/gen-facts.mjs +7 -9
- package/pipeline/scripts/jira-attach.sh +23 -28
- package/pipeline/scripts/jira-search.sh +5 -21
- package/pipeline/scripts/launch-request.mjs +15 -9
- package/pipeline/scripts/migrate-prefs.mjs +56 -0
- package/pipeline/scripts/phase-tracker.sh +226 -50
- package/pipeline/scripts/priority-review.mjs +14 -7
- package/pipeline/scripts/product-context.mjs +26 -7
- package/pipeline/scripts/prune-logs.sh +4 -2
- package/pipeline/scripts/render-work-summary.sh +51 -1
- package/pipeline/scripts/report-file.mjs +285 -0
- package/pipeline/scripts/rework-escalation.mjs +19 -4
- package/pipeline/scripts/runs-index.mjs +2 -1
- package/pipeline/scripts/service-read.mjs +19 -17
- package/pipeline/scripts/skill-siblings.mjs +17 -1
- package/pipeline/scripts/status-overview.mjs +20 -10
- package/pipeline/scripts/uninstall.mjs +145 -57
- package/pipeline/scripts/usage-register.mjs +34 -11
- package/pipeline/scripts/usage-report.mjs +31 -26
- package/pipeline/scripts/validate-triage.mjs +11 -1
- package/pipeline/scripts/work-items.mjs +25 -28
- package/pipeline/scripts/write-store-config.mjs +37 -11
- package/pipeline/skills/.skill-manifest.json +4 -4
- package/pipeline/skills/.skills-index.json +1 -1
- package/pipeline/skills/shared/core/multi-agent/SKILL.md +11 -3
- package/pipeline/skills/shared/core/multi-agent-analysis/SKILL.md +2 -0
- package/pipeline/skills/shared/core/multi-agent-channels/SKILL.md +11 -8
- package/pipeline/lib/credential-resolve.mjs +0 -75
|
@@ -34,32 +34,16 @@ while [ $# -gt 0 ]; do
|
|
|
34
34
|
done
|
|
35
35
|
[ -n "$JQL" ] || { echo "jira-search: --jql is required" >&2; exit 2; }
|
|
36
36
|
|
|
37
|
-
PREFS="${MA_PREFS_FILE:-$HOME/.claude/multi-agent-preferences.json}"
|
|
38
|
-
[ -f "$PREFS" ] || { echo "jira-search: no preferences file" >&2; exit 1; }
|
|
39
37
|
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
#
|
|
43
|
-
|
|
44
|
-
import json, sys, shlex
|
|
45
|
-
try:
|
|
46
|
-
g = json.load(open(sys.argv[1]))["global"]
|
|
47
|
-
except Exception:
|
|
48
|
-
g = {}
|
|
49
|
-
host = (g.get("hosts") or {}).get("jira", "")
|
|
50
|
-
key = (g.get("keychainMapping") or {}).get("jira", "")
|
|
51
|
-
print(f"ACCOUNT_JIRA_HOST={shlex.quote(host)}")
|
|
52
|
-
print(f"ACCOUNT_JIRA_TOKEN_KEY={shlex.quote(key)}")
|
|
53
|
-
PY
|
|
54
|
-
)"
|
|
38
|
+
# Which Jira account answers, and where its credential lives, is the account
|
|
39
|
+
# resolver's question. ACCOUNT_JIRA_HOST and ACCOUNT_JIRA_TOKEN_KEY are still
|
|
40
|
+
# honoured when a caller sets them: they name an account rather than replacing
|
|
41
|
+
# the check that it may be sent to.
|
|
55
42
|
export ACCOUNT_JIRA_HOST ACCOUNT_JIRA_TOKEN_KEY
|
|
56
|
-
[ -n "$ACCOUNT_JIRA_HOST" ] && [ -n "$ACCOUNT_JIRA_TOKEN_KEY" ] || {
|
|
57
|
-
echo "jira-search: jira is not onboarded (host or keychainMapping.jira missing)" >&2
|
|
58
|
-
exit 1
|
|
59
|
-
}
|
|
60
43
|
|
|
61
44
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
62
45
|
for cand in "$HERE/../lib/issue-fetcher.sh" "$HOME/.claude/lib/issue-fetcher.sh"; do
|
|
46
|
+
# shellcheck source=/dev/null
|
|
63
47
|
[ -f "$cand" ] && { . "$cand"; break; }
|
|
64
48
|
done
|
|
65
49
|
command -v jira_search >/dev/null 2>&1 || {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
*
|
|
37
37
|
* - a structured reference: a Jira key, a GitHub issue URL
|
|
38
38
|
* (https://github.com/<owner>/<repo>/issues/<n>), repo#N, #N, or a Jira
|
|
39
|
-
* URL on the
|
|
40
|
-
*
|
|
39
|
+
* URL on the host this machine's Jira account names. It reaches the
|
|
40
|
+
* prompt as it is;
|
|
41
41
|
* - free text (the bearer route, the CLI, and a request file Phase 0
|
|
42
42
|
* reads): one line of at most FREE_TEXT_MAX printable
|
|
43
43
|
* characters, no quote, backslash or backtick, reaching the prompt as one
|
|
@@ -109,7 +109,8 @@ import { lockTimeoutFrom, updateJsonFileSync } from "../lib/json-file-lock.mjs";
|
|
|
109
109
|
import { unattendedSettingsPath } from "../lib/unattended-settings-location.mjs";
|
|
110
110
|
import { isUnattended } from "../lib/unattended.mjs";
|
|
111
111
|
import { listRuns, logsRoot } from "./_run-paths.mjs";
|
|
112
|
-
import {
|
|
112
|
+
import { prefsPath, readPrefsFile } from "../lib/prefs-value.mjs";
|
|
113
|
+
import { selectAccount } from "../lib/service-account.mjs";
|
|
113
114
|
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
114
115
|
|
|
115
116
|
exitOnHelp(import.meta.url);
|
|
@@ -173,14 +174,19 @@ const normalizeHost = (h) =>
|
|
|
173
174
|
.replace(/:.*$/, "")
|
|
174
175
|
.replace(/\.$/, "");
|
|
175
176
|
|
|
176
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* The host of this machine's Jira account, or "" when no account answers.
|
|
179
|
+
*
|
|
180
|
+
* A Jira URL is a structured reference only on that host; anything else is
|
|
181
|
+
* free text. The account resolver decides, so a machine with two Jira
|
|
182
|
+
* instances is asked rather than guessed at, and a file that names no account
|
|
183
|
+
* makes every Jira URL free text instead of a reference to a host nobody
|
|
184
|
+
* configured.
|
|
185
|
+
*/
|
|
177
186
|
export function configuredJiraHost(env = process.env) {
|
|
178
187
|
const file = prefsPath(env, { envVar: "MA_PREFS_FILE" });
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
} catch {
|
|
182
|
-
return "";
|
|
183
|
-
}
|
|
188
|
+
const chosen = selectAccount({ service: "jira" }, { env, prefs: readPrefsFile(file).prefs });
|
|
189
|
+
return chosen.ok ? (chosen.account.hosts[0] ?? "") : "";
|
|
184
190
|
}
|
|
185
191
|
|
|
186
192
|
/** The words the dispatcher's routing table routes on: the first word of each row's pattern. */
|
|
@@ -19,6 +19,7 @@ import { canonicalEndpoint } from "../lib/usage-endpoint.mjs";
|
|
|
19
19
|
import { lockTimeoutFrom, withFileLockSync, writeJsonAtomicSync } from "../lib/json-file-lock.mjs";
|
|
20
20
|
import { prefsFileIn } from "../lib/prefs-value.mjs";
|
|
21
21
|
import { migrateServerPrefs } from "../lib/mcp-rename.mjs";
|
|
22
|
+
import { effectiveAccounts, projectLegacy, reconcileAccounts } from "../lib/service-account.mjs";
|
|
22
23
|
import { ArgsError, parseArgs as parseArgv } from "../lib/args.mjs";
|
|
23
24
|
|
|
24
25
|
const DEFAULT_FILE = prefsFileIn(os.homedir());
|
|
@@ -227,6 +228,55 @@ function defaultTriageCrossCheck() {
|
|
|
227
228
|
return { enabled: false, samplePct: 10, model: "sonnet", blockOnDisagreement: false };
|
|
228
229
|
}
|
|
229
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Derive `serviceAccounts[]` from the flat credential keys.
|
|
233
|
+
*
|
|
234
|
+
* What it will not do is guess. Where the file holds one token and one host for
|
|
235
|
+
* a service, that pair is the only one the data allows and it is written. Where
|
|
236
|
+
* it holds more of either and nothing says which goes with which, the entry is
|
|
237
|
+
* written with `unresolved` instead of a host, which the resolver refuses and
|
|
238
|
+
* setup asks a person about. A token sent to a host nobody paired it with is
|
|
239
|
+
* the failure this whole change exists to prevent, so the migration may not
|
|
240
|
+
* introduce one.
|
|
241
|
+
*
|
|
242
|
+
* Idempotent: a second run reconciles its own output and finds nothing to say.
|
|
243
|
+
*/
|
|
244
|
+
function buildServiceAccounts(out, changes) {
|
|
245
|
+
const g = out.global;
|
|
246
|
+
const before = JSON.stringify(g.serviceAccounts ?? null);
|
|
247
|
+
const { accounts, notes } = reconcileAccounts(out);
|
|
248
|
+
if (JSON.stringify(accounts) !== before) {
|
|
249
|
+
g.serviceAccounts = accounts;
|
|
250
|
+
const unpaired = accounts.filter((a) => a.unresolved).length;
|
|
251
|
+
changes.push(
|
|
252
|
+
`serviceAccounts: ${accounts.length} account(s) derived from keychainMapping and hosts` +
|
|
253
|
+
(unpaired ? `, ${unpaired} waiting for a host` : ""),
|
|
254
|
+
);
|
|
255
|
+
for (const note of notes) changes.push(`serviceAccounts: ${note}`);
|
|
256
|
+
}
|
|
257
|
+
if (!Array.isArray(g.serviceOptOuts)) {
|
|
258
|
+
g.serviceOptOuts = [];
|
|
259
|
+
changes.push("added empty serviceOptOuts");
|
|
260
|
+
}
|
|
261
|
+
// identities[] is deliberately left byte-identical. An identity id is derived
|
|
262
|
+
// from the name on every read, so an account can point at one without the
|
|
263
|
+
// file carrying it; it is persisted the first time a person adds an account
|
|
264
|
+
// through setup, which is a write they asked for. Renaming an identity before
|
|
265
|
+
// that happens orphans the link, and the resolver says so and refuses rather
|
|
266
|
+
// than quietly binding the account to whoever now answers to that name.
|
|
267
|
+
// The flat keys stay the projection of the accounts, so everything still
|
|
268
|
+
// reading them keeps reading the same answer. Only absent keys are filled;
|
|
269
|
+
// a value already there is left alone, because this step has no business
|
|
270
|
+
// overruling something a person set.
|
|
271
|
+
const legacy = projectLegacy(effectiveAccounts(out).accounts);
|
|
272
|
+
for (const [key, value] of Object.entries(legacy.hosts)) {
|
|
273
|
+
if (!g.hosts?.[key]) {
|
|
274
|
+
g.hosts = { ...g.hosts, [key]: value };
|
|
275
|
+
changes.push(`hosts.${key}: filled from the account that holds it`);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
230
280
|
function migrate(prefs) {
|
|
231
281
|
const changes = [];
|
|
232
282
|
const out = JSON.parse(JSON.stringify(prefs)); // deep clone
|
|
@@ -470,6 +520,12 @@ function migrate(prefs) {
|
|
|
470
520
|
// 15. The MCP server renamed: guard rules and devToolkit fields that name it.
|
|
471
521
|
migrateServerPrefs(out, changes);
|
|
472
522
|
|
|
523
|
+
// 16. serviceAccounts[]: the host, the secret and the identity of one
|
|
524
|
+
// credential on one entry. Runs last, because it reads the flat keys every
|
|
525
|
+
// step above may still have been fixing. Idempotent, and it rewrites no
|
|
526
|
+
// legacy value: the flat keys stay exactly where everything else reads them.
|
|
527
|
+
buildServiceAccounts(out, changes);
|
|
528
|
+
|
|
473
529
|
return { out, changes, alreadyMigrated: changes.length === 0 };
|
|
474
530
|
}
|
|
475
531
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
#
|
|
19
19
|
# Commands:
|
|
20
20
|
# init <task_id> Reset tracker for this task
|
|
21
|
-
# add <phase_id> "<name>" Register a phase (status=pending); idempotent - existing id is a no-op
|
|
21
|
+
# add <phase_id> "<name>" Register a phase and its contract sub-steps (status=pending); idempotent - existing id is a no-op
|
|
22
22
|
# update <phase_id> <status> Change status + re-render
|
|
23
23
|
# sub <phase_id> <sub_id> "<name>" [status] Add or update a sub-phase
|
|
24
24
|
# tokens <phase_id> <in> <out> [cached] Add to phase's token totals (in = fresh input, cache-exclusive)
|
|
@@ -129,6 +129,24 @@ waiting_word() {
|
|
|
129
129
|
esac
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
# The sub-steps each phase declares before it starts, keyed `<id>:<name>` so a
|
|
133
|
+
# mode that renames a slot only inherits the set when the slot is the same one.
|
|
134
|
+
# Held to pipeline/schemas/phases.json `steps` by smoke-phase-tracker.sh, which
|
|
135
|
+
# compares the two sets; it stays a case statement here for the same reason
|
|
136
|
+
# phase-banner.sh keeps its label table (ADR-0004, no runtime schema read).
|
|
137
|
+
#
|
|
138
|
+
# Dev is absent on purpose: its sub-steps are Phase 1's plan tasks, which `plan`
|
|
139
|
+
# attaches once they exist. Declaring a second set would put two lists of work
|
|
140
|
+
# under one phase.
|
|
141
|
+
phase_steps() {
|
|
142
|
+
case "$1" in
|
|
143
|
+
0:Init) printf 'Intake\nWorkspace\nTask contract\n' ;;
|
|
144
|
+
1:Plan) printf 'Context\nExploration\nTask breakdown\n' ;;
|
|
145
|
+
3:Review) printf 'Gates\nReview panel\nTriage\n' ;;
|
|
146
|
+
4:Commit) printf 'Commit\nPush\nPull request\n' ;;
|
|
147
|
+
5:Report) printf 'Channels dispatch\nLog + telemetry\nKnowledge + memory\n' ;;
|
|
148
|
+
esac
|
|
149
|
+
}
|
|
132
150
|
|
|
133
151
|
if [ "$#" -lt 1 ]; then
|
|
134
152
|
cat >&2 <<USAGE
|
|
@@ -779,12 +797,12 @@ tracker_next_hint() {
|
|
|
779
797
|
# default only up to Opus 4.7 / Sonnet 4.6, a default that landed in
|
|
780
798
|
# v2.1.268. Naming the fallback on the same line is what keeps a newer model
|
|
781
799
|
# from advancing six phases in silence.
|
|
782
|
-
# `
|
|
783
|
-
# update_plan takes the whole list anyway, so re-reading it is what puts
|
|
784
|
-
#
|
|
800
|
+
# `tiles` prints the whole payload with each row's current status, and
|
|
801
|
+
# update_plan takes the whole list anyway, so re-reading it is what puts the
|
|
802
|
+
# sub-steps on the Codex plan without a second mechanism. Codex has no
|
|
785
803
|
# dependency concept; the "(waiting on: ...)" suffix inside the step text is
|
|
786
804
|
# where that information survives on this host.
|
|
787
|
-
codex) mirror="update_plan: set step \"Phase $pid $name\" to $status, re-reading the FULL
|
|
805
|
+
codex) mirror="update_plan: set step \"Phase $pid $name\" to $status, re-reading the FULL payload from \`phase-tracker.sh tiles\` (it is not a delta, and the indented rows are plan steps that belong in it)" ;;
|
|
788
806
|
*) mirror="no task widget on this host - reprint the card above inside your reply text" ;;
|
|
789
807
|
esac
|
|
790
808
|
printf '\n-- NEXT (required) --\n %s\n' "$mirror"
|
|
@@ -795,6 +813,23 @@ tracker_next_hint() {
|
|
|
795
813
|
esac
|
|
796
814
|
}
|
|
797
815
|
|
|
816
|
+
# Printed after every sub-step change, for the same reason the phase hint is:
|
|
817
|
+
# the card goes to stdout and the host collapses it, so a sub-step that moves
|
|
818
|
+
# only in the state file moves nowhere the user can see. The row text is the
|
|
819
|
+
# one `subjects` prints, so the tile it names is the tile that exists.
|
|
820
|
+
sub_next_hint() {
|
|
821
|
+
local pid="$1" sid="$2" status="$3" row mirror
|
|
822
|
+
[ "${TRACKER_QUIET:-0}" = "1" ] && return 0
|
|
823
|
+
row=$(sub_rows "$(load_state)" "$pid" "$sid")
|
|
824
|
+
[ -n "$row" ] || return 0
|
|
825
|
+
case "$(host_kind)" in
|
|
826
|
+
claude) mirror="TaskUpdate(<tile \"$row\">, status=\"$status\") - the sub-step is a tile of its own, created from \`phase-tracker.sh tiles\`; if it has no tile yet, re-run \`tiles\` and rebuild the list first" ;;
|
|
827
|
+
codex) mirror="update_plan: set step \"$row\" to $status, re-reading the FULL list from \`phase-tracker.sh tiles\` (it is not a delta)" ;;
|
|
828
|
+
*) mirror="no task widget on this host - reprint the card above inside your reply text" ;;
|
|
829
|
+
esac
|
|
830
|
+
printf '\n-- NEXT (required) --\n %s\n' "$mirror"
|
|
831
|
+
}
|
|
832
|
+
|
|
798
833
|
# Elapsed with an hours bucket. format_elapsed stops at minutes because the card
|
|
799
834
|
# shows one phase at a time; a whole-run total reads as "102m" without this.
|
|
800
835
|
format_span() {
|
|
@@ -883,6 +918,48 @@ EOF
|
|
|
883
918
|
# Every segment is omitted while it is empty, so a pending phase is just its name
|
|
884
919
|
# and a finished one carries its whole bill. Separator is ` - `, not a middle dot:
|
|
885
920
|
# a subject is a task title and travels through surfaces that are not a terminal.
|
|
921
|
+
# A task subject is a title: it travels through surfaces that are not a terminal
|
|
922
|
+
# and a host truncates it where it likes, so the length is ours to decide. The
|
|
923
|
+
# action is the only segment that grows without a bound, so it is last and it is
|
|
924
|
+
# the one that gets shortened; the phase, its elapsed time and its step counter
|
|
925
|
+
# are what a reader scans for and never drop.
|
|
926
|
+
#
|
|
927
|
+
# Order of sacrifice when the line is too long: the cost, which comes back when
|
|
928
|
+
# the phase completes; then the action, down to a floor below which it says
|
|
929
|
+
# nothing; then the tokens; then the model.
|
|
930
|
+
SUBJECT_MAX=96
|
|
931
|
+
SUBJECT_ACTION_FLOOR=24
|
|
932
|
+
|
|
933
|
+
# Each segment arrives on its own so the drop order is the code rather than a
|
|
934
|
+
# claim about it: nothing has to be parsed back out of an assembled line.
|
|
935
|
+
compose_subject() {
|
|
936
|
+
local phase="$1" model="$2" elapsed="$3" tok="$4" cost="$5" step="$6" act="$7" line
|
|
937
|
+
_subject_fits() { line="$phase$model$elapsed$tok$cost$step$act"; [ "${#line}" -le "$SUBJECT_MAX" ]; }
|
|
938
|
+
|
|
939
|
+
_subject_fits && { printf '%s' "$line"; return 0; }
|
|
940
|
+
cost=""
|
|
941
|
+
_subject_fits && { printf '%s' "$line"; return 0; }
|
|
942
|
+
|
|
943
|
+
if [ -n "$act" ]; then
|
|
944
|
+
local room=$(( SUBJECT_MAX - ${#phase} - ${#model} - ${#elapsed} - ${#tok} - ${#step} - 6 ))
|
|
945
|
+
if [ "$room" -ge "$SUBJECT_ACTION_FLOOR" ]; then
|
|
946
|
+
act=" - ${act:3:$room}..."
|
|
947
|
+
_subject_fits && { printf '%s' "$line"; return 0; }
|
|
948
|
+
fi
|
|
949
|
+
fi
|
|
950
|
+
|
|
951
|
+
tok=""
|
|
952
|
+
_subject_fits && { printf '%s' "$line"; return 0; }
|
|
953
|
+
|
|
954
|
+
# The model is the last to go: without it a reader cannot tell what is
|
|
955
|
+
# spending, and by this point the action has already been cut to its floor.
|
|
956
|
+
# The phase, its elapsed time and its counter stay, which is what the order
|
|
957
|
+
# above promises.
|
|
958
|
+
model=""
|
|
959
|
+
_subject_fits && { printf '%s' "$line"; return 0; }
|
|
960
|
+
printf '%s' "$line"
|
|
961
|
+
}
|
|
962
|
+
|
|
886
963
|
subjects() {
|
|
887
964
|
need_jq
|
|
888
965
|
local state want="${1:-}" new_only=""
|
|
@@ -911,17 +988,20 @@ subjects() {
|
|
|
911
988
|
(.id // ""), (.name // ""), (.status // ""),
|
|
912
989
|
(.started_at // ""), (.completed_at // ""), (.model // ""),
|
|
913
990
|
(((.tokens_in // 0) + (.tokens_out // 0)) | tostring),
|
|
914
|
-
(usd_of(.) | if . == null then "" else (((. * 100) | floor) / 100 | tostring) end)
|
|
991
|
+
(usd_of(.) | if . == null then "" else (((. * 100) | floor) / 100 | tostring) end),
|
|
992
|
+
([.subs[]? | select(.status == "completed")] | length | tostring),
|
|
993
|
+
([.subs[]?] | length | tostring),
|
|
994
|
+
(. as $p | ($p.meta.Now // "") | if . == "" then ([$p.subs[]? | select(.status == "in_progress") | .name] | first // "") else . end)
|
|
915
995
|
] | join("\u001f")')
|
|
916
|
-
local pid pname pstatus p_start p_end pmodel ptok pusd
|
|
917
|
-
while IFS=$'\x1f' read -r pid pname pstatus p_start p_end pmodel ptok pusd; do
|
|
996
|
+
local pid pname pstatus p_start p_end pmodel ptok pusd pdone ptotal paction
|
|
997
|
+
while IFS=$'\x1f' read -r pid pname pstatus p_start p_end pmodel ptok pusd pdone ptotal paction; do
|
|
918
998
|
[ -n "$pid" ] || continue
|
|
919
999
|
[ -z "$want" ] || [ "$want" = "$pid" ] || continue
|
|
920
1000
|
if [ -n "$new_only" ]; then
|
|
921
1001
|
case "$new_ids" in *" $pid "*) ;; *) continue ;; esac
|
|
922
1002
|
fi
|
|
923
|
-
local
|
|
924
|
-
[ -n "$pmodel" ] &&
|
|
1003
|
+
local seg_phase="Phase $pid $pname" seg_model=""
|
|
1004
|
+
[ -n "$pmodel" ] && seg_model=" - $pmodel"
|
|
925
1005
|
local s_ep e_ep el=""
|
|
926
1006
|
s_ep=$(iso_to_epoch "$p_start")
|
|
927
1007
|
e_ep=$(iso_to_epoch "$p_end")
|
|
@@ -932,11 +1012,26 @@ subjects() {
|
|
|
932
1012
|
esac
|
|
933
1013
|
fi
|
|
934
1014
|
if [ -n "$el" ] && [ "$el" -lt 0 ] 2>/dev/null; then el=0; fi
|
|
935
|
-
|
|
1015
|
+
local seg_el=""
|
|
1016
|
+
[ -n "$el" ] && seg_el=" - $(format_elapsed "$el")"
|
|
1017
|
+
local seg_tok="" seg_cost=""
|
|
936
1018
|
if [ "${ptok:-0}" -gt 0 ] 2>/dev/null; then
|
|
937
|
-
|
|
938
|
-
[ -n "$pusd" ] &&
|
|
1019
|
+
seg_tok=" - $(format_tokens "$ptok") tok"
|
|
1020
|
+
[ -n "$pusd" ] && seg_cost=" - $(printf '~$%.2f' "$pusd" 2>/dev/null || echo '')"
|
|
939
1021
|
fi
|
|
1022
|
+
# The counter and the action belong to a phase that is running or stopped in
|
|
1023
|
+
# place. On a finished phase they would describe a moment that has passed,
|
|
1024
|
+
# and on a pending one there is nothing to describe.
|
|
1025
|
+
local seg_step="" seg_act=""
|
|
1026
|
+
case "$pstatus" in
|
|
1027
|
+
in_progress|failed)
|
|
1028
|
+
[ "${ptotal:-0}" -gt 0 ] 2>/dev/null && seg_step=" - step ${pdone:-0}/${ptotal}"
|
|
1029
|
+
[ -n "$paction" ] && seg_act=" - $paction"
|
|
1030
|
+
;;
|
|
1031
|
+
esac
|
|
1032
|
+
local line
|
|
1033
|
+
line=$(compose_subject "$seg_phase" "$seg_model" "$seg_el" \
|
|
1034
|
+
"$seg_tok" "$seg_cost" "$seg_step" "$seg_act")
|
|
940
1035
|
printf '%s\n' "$line"
|
|
941
1036
|
|
|
942
1037
|
# Sub-phases ride out on the SAME list, indented in the subject string.
|
|
@@ -950,18 +1045,34 @@ subjects() {
|
|
|
950
1045
|
# Indentation is two spaces INSIDE the subject because the widget takes
|
|
951
1046
|
# exactly one string per row and has no parent field - there is no nesting
|
|
952
1047
|
# to ask for, so the only place a hierarchy can be expressed is the string.
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
1048
|
+
#
|
|
1049
|
+
# The row carries `<phase>.<step>` and not the bare step id because the
|
|
1050
|
+
# number has to survive in the string: the widget renders one string per row
|
|
1051
|
+
# and no field beside it, so a `1` on its own row says nothing about which
|
|
1052
|
+
# phase it belongs to.
|
|
1053
|
+
#
|
|
1054
|
+
# A single-phase read (`subjects <id>`) is the subject of ONE tile and stays
|
|
1055
|
+
# one line; the sub rows are tiles of their own and belong to the full list.
|
|
1056
|
+
if [ -z "$want" ]; then
|
|
1057
|
+
sub_rows "$state" "$pid"
|
|
961
1058
|
fi
|
|
962
1059
|
done <<< "$rows"
|
|
963
1060
|
}
|
|
964
1061
|
|
|
1062
|
+
# The sub rows of one phase, in the shape every host puts on its widget.
|
|
1063
|
+
# `sid` narrows to a single step, which is what a per-step mirror call needs.
|
|
1064
|
+
sub_rows() {
|
|
1065
|
+
local state="$1" pid="$2" sid="${3:-}"
|
|
1066
|
+
echo "$state" | jq -r --arg pid "$pid" --arg sid "$sid" --arg waiting "$(waiting_word)" '
|
|
1067
|
+
([.phases[] | select(.id == $pid)][0].subs) // []
|
|
1068
|
+
| .[]
|
|
1069
|
+
| select($sid == "" or (.id // "") == $sid)
|
|
1070
|
+
| " " + $pid + "." + (.id // "") + " " + (.name // "")
|
|
1071
|
+
+ (if ((.deps // []) | length) > 0
|
|
1072
|
+
then " (" + $waiting + ": " + ((.deps // []) | join(", ")) + ")"
|
|
1073
|
+
else "" end)'
|
|
1074
|
+
}
|
|
1075
|
+
|
|
965
1076
|
# The TaskCreate/TaskUpdate script for this host, in creation order.
|
|
966
1077
|
#
|
|
967
1078
|
# Creation order is the ONLY ordering the native widget has - it renders by the
|
|
@@ -971,14 +1082,20 @@ subjects() {
|
|
|
971
1082
|
# already does for a different reason.
|
|
972
1083
|
tiles_script() {
|
|
973
1084
|
need_jq
|
|
974
|
-
local new_only="${1:-}"
|
|
1085
|
+
local new_only="${1:-}" rebuild="${2:-}"
|
|
975
1086
|
local state; state=$(load_state)
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
1087
|
+
# A phase whose tasklist_id was never recorded has, as far as anything can
|
|
1088
|
+
# tell, no tile. With none recorded at all there is no list yet, so the whole
|
|
1089
|
+
# list is a first batch and nothing is rebuilt.
|
|
1090
|
+
local has_tiles
|
|
1091
|
+
has_tiles=$(echo "$state" | jq \
|
|
1092
|
+
'[.phases[]? | select(((.meta.tasklist_id // "") | tostring) != "")] | length')
|
|
1093
|
+
[ "${has_tiles:-0}" -gt 0 ] || rebuild=""
|
|
1094
|
+
|
|
1095
|
+
# Rows that arrive after the list exists have to be inserted, which the widget
|
|
1096
|
+
# cannot do, so the whole list is rebuilt. The rebuild wins over a narrowed
|
|
1097
|
+
# batch: appending to it would land the new rows after the last phase.
|
|
1098
|
+
[ -n "$rebuild" ] && new_only=""
|
|
982
1099
|
|
|
983
1100
|
if [ -n "$new_only" ]; then
|
|
984
1101
|
local pending_new
|
|
@@ -987,19 +1104,21 @@ tiles_script() {
|
|
|
987
1104
|
printf 'Every registered phase already has a tile - nothing to create.\n'
|
|
988
1105
|
return 0
|
|
989
1106
|
fi
|
|
990
|
-
printf 'REQUIRED - create one native tile per
|
|
1107
|
+
printf 'REQUIRED - create one native tile per ROW below, in this exact order.
|
|
991
1108
|
'
|
|
992
1109
|
printf 'Tiles already created keep their place; every phase here is numbered
|
|
993
1110
|
'
|
|
994
|
-
printf 'above them, so the widget stays in phase order.
|
|
1111
|
+
printf 'above them, so the widget stays in phase order. The indented rows are
|
|
1112
|
+
'
|
|
1113
|
+
printf 'the sub-steps of the phase above them and are tiles of their own.
|
|
995
1114
|
|
|
996
1115
|
'
|
|
997
1116
|
printf '%s\n' "$pending_new" | sed 's/^/ TaskCreate(subject: "/; s/$/")/'
|
|
998
1117
|
return 0
|
|
999
1118
|
fi
|
|
1000
1119
|
|
|
1001
|
-
if [ "$
|
|
1002
|
-
printf 'The tile list has
|
|
1120
|
+
if [ -n "$rebuild" ]; then
|
|
1121
|
+
printf 'The tile list has gained rows, and the widget orders by CREATION.
|
|
1003
1122
|
'
|
|
1004
1123
|
printf 'Delete every existing tile (TaskUpdate status="deleted"), then create
|
|
1005
1124
|
'
|
|
@@ -1009,11 +1128,15 @@ tiles_script() {
|
|
|
1009
1128
|
|
|
1010
1129
|
'
|
|
1011
1130
|
else
|
|
1012
|
-
printf 'REQUIRED - create one native tile per
|
|
1131
|
+
printf 'REQUIRED - create one native tile per ROW below, in this exact
|
|
1132
|
+
'
|
|
1133
|
+
printf 'order, BEFORE any TaskUpdate. The indented rows are the sub-steps of
|
|
1013
1134
|
'
|
|
1014
|
-
printf '
|
|
1135
|
+
printf 'the phase above them and are tiles of their own; the widget renders by
|
|
1015
1136
|
'
|
|
1016
|
-
printf 'phase number, so an out-of-order call scrambles
|
|
1137
|
+
printf 'creation order, not by phase number, so an out-of-order call scrambles
|
|
1138
|
+
'
|
|
1139
|
+
printf 'the stack.
|
|
1017
1140
|
|
|
1018
1141
|
'
|
|
1019
1142
|
fi
|
|
@@ -1029,12 +1152,13 @@ tiles_script() {
|
|
|
1029
1152
|
# executable and is not, which is worse than a line that admits what it needs.
|
|
1030
1153
|
local deps
|
|
1031
1154
|
deps=$(echo "$state" | jq -r '
|
|
1032
|
-
[.phases[]? | .subs[]?] as $all
|
|
1033
|
-
| $
|
|
1155
|
+
[.phases[]? | . as $p | (.subs[]? | . + {phase: $p.id})] as $all
|
|
1156
|
+
| def row($s): "<tile \" " + ($s.phase // "") + "." + ($s.id // "") + " " + ($s.name // "") + "\">";
|
|
1157
|
+
$all[] | select(((.deps // []) | length) > 0)
|
|
1034
1158
|
| . as $s
|
|
1035
|
-
| " TaskUpdate(
|
|
1159
|
+
| " TaskUpdate(" + row($s) + ", addBlockedBy: [" +
|
|
1036
1160
|
(($s.deps // [])
|
|
1037
|
-
| map(. as $d | (($all[] | select(.id == $d
|
|
1161
|
+
| map(. as $d | (($all[] | select(.id == $d and .phase == $s.phase) | row(.)) // $d))
|
|
1038
1162
|
| join(", ")) + "])"')
|
|
1039
1163
|
if [ -n "$deps" ]; then
|
|
1040
1164
|
printf '\nThen the dependencies, so the widget says WHY a step has not started.\n'
|
|
@@ -1044,6 +1168,29 @@ tiles_script() {
|
|
|
1044
1168
|
fi
|
|
1045
1169
|
}
|
|
1046
1170
|
|
|
1171
|
+
# The Codex plan payload: every row `subjects` prints, carrying the status the
|
|
1172
|
+
# tracker holds for it. The indented rows are plan steps like any other - the
|
|
1173
|
+
# plan tool has no nesting, so the phase number inside the text is the only
|
|
1174
|
+
# thing that says which phase a step belongs to. Codex knows three statuses, so
|
|
1175
|
+
# a failed or skipped row goes out as `completed` and the agent log carries why.
|
|
1176
|
+
codex_plan() {
|
|
1177
|
+
local state="$1" statuses
|
|
1178
|
+
statuses=$(echo "$state" | jq -r '
|
|
1179
|
+
.phases // []
|
|
1180
|
+
| sort_by(.id | (tonumber? // 9999))
|
|
1181
|
+
| .[]
|
|
1182
|
+
| select((.id // "") != "")
|
|
1183
|
+
| (.status // "pending"), ((.subs // [])[] | (.status // "pending"))')
|
|
1184
|
+
paste -d"$(printf '\037')" <(subjects) <(printf '%s\n' "$statuses") \
|
|
1185
|
+
| jq -Rn -c '[inputs | select(length > 0) | split("\u001f") | . as $r
|
|
1186
|
+
| {step: $r[0],
|
|
1187
|
+
status: (if $r[1] == "in_progress" then "in_progress"
|
|
1188
|
+
elif ($r[1] == "completed" or $r[1] == "failed" or $r[1] == "skipped")
|
|
1189
|
+
then "completed"
|
|
1190
|
+
else "pending" end)}]
|
|
1191
|
+
| {plan: .}'
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1047
1194
|
render() {
|
|
1048
1195
|
need_jq
|
|
1049
1196
|
local state
|
|
@@ -1086,20 +1233,21 @@ render() {
|
|
|
1086
1233
|
((.tokens_out // 0) | tostring),
|
|
1087
1234
|
((.subs // []) | length | tostring),
|
|
1088
1235
|
((.meta // {}) | keys_unsorted | join(",")),
|
|
1236
|
+
(.model // ""),
|
|
1089
1237
|
(usd_of(.) | if . == null then "" else (((. * 100) | floor) / 100 | tostring) end)
|
|
1090
1238
|
] | join("")
|
|
1091
1239
|
')
|
|
1092
1240
|
|
|
1093
1241
|
local phase_count=0
|
|
1094
1242
|
local -a row_status=() row_started=() row_completed=() row_id=() row_name=()
|
|
1095
|
-
local -a row_tin=() row_tout=() row_subcount=() row_metakeys=() row_usd=()
|
|
1243
|
+
local -a row_tin=() row_tout=() row_subcount=() row_metakeys=() row_usd=() row_model=()
|
|
1096
1244
|
if [ -n "$phase_data" ]; then
|
|
1097
|
-
local _s _st _ed _id _nm _ti _to _sc _mk _us
|
|
1098
|
-
while IFS=$'\x1f' read -r _s _st _ed _id _nm _ti _to _sc _mk _us; do
|
|
1245
|
+
local _s _st _ed _id _nm _ti _to _sc _mk _md _us
|
|
1246
|
+
while IFS=$'\x1f' read -r _s _st _ed _id _nm _ti _to _sc _mk _md _us; do
|
|
1099
1247
|
row_status+=("$_s"); row_started+=("$_st"); row_completed+=("$_ed")
|
|
1100
1248
|
row_id+=("$_id"); row_name+=("$_nm")
|
|
1101
1249
|
row_tin+=("$_ti"); row_tout+=("$_to")
|
|
1102
|
-
row_subcount+=("$_sc"); row_metakeys+=("$_mk"); row_usd+=("$_us")
|
|
1250
|
+
row_subcount+=("$_sc"); row_metakeys+=("$_mk"); row_usd+=("$_us"); row_model+=("$_md")
|
|
1103
1251
|
phase_count=$((phase_count + 1))
|
|
1104
1252
|
done <<< "$phase_data"
|
|
1105
1253
|
fi
|
|
@@ -1179,6 +1327,13 @@ render() {
|
|
|
1179
1327
|
fi
|
|
1180
1328
|
[ -n "$usd_label" ] && [ -n "$tok_label" ] && tok_label="${tok_label} · ${usd_label}"
|
|
1181
1329
|
|
|
1330
|
+
# The model belongs beside the bill it explains: a phase's cost means
|
|
1331
|
+
# nothing without knowing which model spent it, and on the card there is
|
|
1332
|
+
# room to say so plainly.
|
|
1333
|
+
local p_model="${row_model[$i]}"
|
|
1334
|
+
[ -n "$p_model" ] && [ -n "$tok_label" ] && tok_label="${p_model} · ${tok_label}"
|
|
1335
|
+
[ -n "$p_model" ] && [ -z "$tok_label" ] && tok_label="$p_model"
|
|
1336
|
+
|
|
1182
1337
|
local right_block=""
|
|
1183
1338
|
if [ -n "$el_label" ] && [ -n "$tok_label" ]; then
|
|
1184
1339
|
right_block=$(printf "%b%s%b ${C_DIM}·${C_RESET} %b%s%b" "$el_color" "$el_label" "$C_RESET" "$C_DIM" "$tok_label" "$C_RESET")
|
|
@@ -1302,15 +1457,23 @@ case "$ACTION" in
|
|
|
1302
1457
|
need_jq
|
|
1303
1458
|
[ "$#" -ge 2 ] || { echo "add needs <phase_id> <name>" >&2; exit 64; }
|
|
1304
1459
|
PID="$1"; PNAME="$(decode_entities "$2")"
|
|
1460
|
+
# The phase arrives with its sub-steps already on it. A step registered from
|
|
1461
|
+
# the contract is a property of the phase set, and so reaches the widget
|
|
1462
|
+
# whether or not the phase later announces it; one a phase has to announce
|
|
1463
|
+
# before it exists reaches the widget only when that call is made.
|
|
1464
|
+
PSUBS=$(phase_steps "$PID:$PNAME" | jq -Rn \
|
|
1465
|
+
'[inputs | select(length > 0)]
|
|
1466
|
+
| to_entries
|
|
1467
|
+
| map({id: ((.key + 1) | tostring), name: .value, status: "pending", deps: []})')
|
|
1305
1468
|
acquire_state_lock
|
|
1306
1469
|
state=$(load_state)
|
|
1307
1470
|
# Idempotent: a phase id that already exists is a no-op (name, status, and
|
|
1308
1471
|
# token history are preserved). This is what lets continuation commands
|
|
1309
1472
|
# (/multi-agent:resume, /multi-agent:manual-test) re-declare their phase set against a
|
|
1310
1473
|
# pre-existing tracker without duplicating or resetting tiles.
|
|
1311
|
-
new=$(echo "$state" | jq --arg id "$PID" --arg name "$PNAME" '
|
|
1474
|
+
new=$(echo "$state" | jq --arg id "$PID" --arg name "$PNAME" --argjson subs "$PSUBS" '
|
|
1312
1475
|
if any(.phases[]?; .id == $id) then .
|
|
1313
|
-
else .phases += [{"id":$id,"name":$name,"status":"pending","subs"
|
|
1476
|
+
else .phases += [{"id":$id,"name":$name,"status":"pending","subs":$subs}]
|
|
1314
1477
|
end')
|
|
1315
1478
|
save_state "$new"
|
|
1316
1479
|
release_state_lock
|
|
@@ -1422,7 +1585,10 @@ $(printf '%s' "$PLAN_IN" | jq -r '
|
|
|
1422
1585
|
EOF
|
|
1423
1586
|
[ "$N" -gt 0 ] || { echo "phase-tracker: plan carried no tasks[]" >&2; exit 65; }
|
|
1424
1587
|
printf 'phase-tracker: %s plan step(s) attached to phase %s\n' "$N" "$PID"
|
|
1425
|
-
|
|
1588
|
+
# The steps arrive after the list exists, so the list is rebuilt - and
|
|
1589
|
+
# through the `tiles` action, so each host is told in its own calls rather
|
|
1590
|
+
# than handed Claude Code's.
|
|
1591
|
+
"$SELF_PATH" tiles --rebuild
|
|
1426
1592
|
;;
|
|
1427
1593
|
sub)
|
|
1428
1594
|
need_jq
|
|
@@ -1456,6 +1622,7 @@ EOF
|
|
|
1456
1622
|
emit_otel_span "phase.sub" "$PID" "$SNAME" \
|
|
1457
1623
|
"$(jq -nc --arg s "$SID" --arg st "$SSTATUS" '{sub_id:$s,status:$st}')"
|
|
1458
1624
|
render
|
|
1625
|
+
sub_next_hint "$PID" "$SID" "$SSTATUS"
|
|
1459
1626
|
;;
|
|
1460
1627
|
|
|
1461
1628
|
tokens)
|
|
@@ -1661,7 +1828,15 @@ EOF
|
|
|
1661
1828
|
tiles)
|
|
1662
1829
|
need_jq
|
|
1663
1830
|
tiles_new=""
|
|
1664
|
-
|
|
1831
|
+
tiles_rebuild=""
|
|
1832
|
+
while [ "$#" -gt 0 ]; do
|
|
1833
|
+
case "$1" in
|
|
1834
|
+
--new) tiles_new=1 ;;
|
|
1835
|
+
--rebuild) tiles_rebuild=1 ;;
|
|
1836
|
+
*) echo "tiles: unknown option $1" >&2; exit 64 ;;
|
|
1837
|
+
esac
|
|
1838
|
+
shift
|
|
1839
|
+
done
|
|
1665
1840
|
tiles_state=$(load_state)
|
|
1666
1841
|
tiles_count=$(echo "$tiles_state" | jq '[.phases[]?] | length')
|
|
1667
1842
|
[ "${tiles_count:-0}" -gt 0 ] || {
|
|
@@ -1684,7 +1859,7 @@ EOF
|
|
|
1684
1859
|
# tools it has. And the fallback is not enough on its own: a user looking
|
|
1685
1860
|
# at a missing widget needs the one command that brings it back, which is
|
|
1686
1861
|
# why the opt-in is printed next to it.
|
|
1687
|
-
tiles_script "$tiles_new"
|
|
1862
|
+
tiles_script "$tiles_new" "$tiles_rebuild"
|
|
1688
1863
|
echo
|
|
1689
1864
|
echo "At every phase boundary re-run \`phase-tracker.sh subjects <id>\` and"
|
|
1690
1865
|
echo "pass that line as the subject of the TaskUpdate. The subject is the only"
|
|
@@ -1709,8 +1884,9 @@ EOF
|
|
|
1709
1884
|
codex)
|
|
1710
1885
|
echo "REQUIRED - register the plan in ONE update_plan call with this step"
|
|
1711
1886
|
echo "list. update_plan takes the full list, not a delta, so every later"
|
|
1712
|
-
echo "boundary resends it with one step's status changed."
|
|
1713
|
-
echo "
|
|
1887
|
+
echo "boundary resends it with one step's status changed. The indented"
|
|
1888
|
+
echo "steps are the sub-steps of the phase above them and belong in it."
|
|
1889
|
+
codex_plan "$tiles_state"
|
|
1714
1890
|
;;
|
|
1715
1891
|
*)
|
|
1716
1892
|
echo "Copilot CLI has no native task widget: the bordered card IS the widget."
|