cool-workflow 0.1.98 → 0.2.1
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/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +18 -7
- package/apps/architecture-review/app.json +2 -2
- package/apps/architecture-review/workflow.js +12 -12
- package/apps/architecture-review-fast/app.json +1 -1
- package/apps/end-to-end-golden-path/app.json +1 -1
- package/apps/pr-review-fix-ci/app.json +1 -1
- package/apps/release-cut/app.json +1 -1
- package/apps/research-synthesis/app.json +1 -1
- package/dist/cli/dispatch.js +236 -0
- package/dist/cli/entry.js +120 -0
- package/dist/cli/io.js +21 -4
- package/dist/cli/parseargv.js +157 -0
- package/dist/cli.js +6 -33
- package/dist/core/capability-table.js +3518 -0
- package/dist/core/format/help.js +314 -0
- package/dist/{state-explosion/format.js → core/format/state-explosion-text.js} +10 -1
- package/dist/core/hash.js +137 -0
- package/dist/core/multi-agent/candidate-scoring.js +219 -0
- package/dist/core/multi-agent/collaboration.js +481 -0
- package/dist/core/multi-agent/coordinator.js +515 -0
- package/dist/core/multi-agent/eval-replay.js +306 -0
- package/dist/core/multi-agent/runtime.js +929 -0
- package/dist/core/multi-agent/topology.js +298 -0
- package/dist/core/multi-agent/trust-policy.js +197 -0
- package/dist/core/pipeline/commit-gate.js +320 -0
- package/dist/{pipeline-contract.js → core/pipeline/contract.js} +24 -37
- package/dist/core/pipeline/dispatch.js +103 -0
- package/dist/core/pipeline/drive-decide.js +227 -0
- package/dist/core/pipeline/error-feedback.js +161 -0
- package/dist/core/pipeline/loop-expansion.js +124 -0
- package/dist/{result-normalize.js → core/pipeline/result-normalize.js} +14 -37
- package/dist/core/pipeline/runner.js +230 -0
- package/dist/{contract-migration.js → core/state/contract-migration.js} +68 -92
- package/dist/{state-migrations.js → core/state/migrations.js} +103 -96
- package/dist/core/state/node-projection.js +95 -0
- package/dist/core/state/node-snapshot.js +230 -0
- package/dist/core/state/run-paths.js +93 -0
- package/dist/{schema-validate.js → core/state/schema-validate.js} +35 -28
- package/dist/core/state/schema.js +50 -0
- package/dist/core/state/state-explosion/digest.js +243 -0
- package/dist/core/state/state-explosion/graph.js +527 -0
- package/dist/{state-explosion → core/state/state-explosion}/helpers.js +34 -3
- package/dist/core/state/state-explosion/report.js +187 -0
- package/dist/{state-explosion → core/state/state-explosion}/size.js +25 -7
- package/dist/{state-node.js → core/state/state-node.js} +90 -113
- package/dist/core/state/types.js +19 -0
- package/dist/{validation.js → core/state/validation.js} +64 -131
- package/dist/core/trust/evidence-grounding.js +134 -0
- package/dist/core/trust/ledger.js +199 -0
- package/dist/{telemetry-attestation.js → core/trust/telemetry-attestation.js} +94 -68
- package/dist/core/trust/telemetry-ledger.js +127 -0
- package/dist/core/types.js +20 -0
- package/dist/core/version.js +16 -0
- package/dist/{workflow-app-framework.js → core/workflow-apps/app-schema.js} +337 -426
- package/dist/mcp/dispatch.js +104 -0
- package/dist/mcp/server.js +144 -0
- package/dist/mcp-server.js +6 -84
- package/dist/{agent-config.js → shell/agent-config.js} +118 -71
- package/dist/shell/app-run-cli.js +88 -0
- package/dist/shell/audit-cli.js +259 -0
- package/dist/shell/audit-provenance.js +83 -0
- package/dist/shell/candidate-scoring-io.js +459 -0
- package/dist/shell/collaboration-io.js +264 -0
- package/dist/shell/commit-summary.js +104 -0
- package/dist/shell/commit.js +290 -0
- package/dist/shell/coordinator-io.js +476 -0
- package/dist/shell/demo-cli.js +19 -0
- package/dist/shell/dispatch.js +162 -0
- package/dist/shell/doctor.js +292 -0
- package/dist/shell/drive.js +885 -0
- package/dist/shell/error-feedback-io.js +305 -0
- package/dist/shell/eval-io.js +473 -0
- package/dist/{multi-agent-eval/format.js → shell/eval-text.js} +78 -49
- package/dist/{evidence-reasoning.js → shell/evidence-reasoning.js} +124 -255
- package/dist/shell/exec-backend-cli.js +88 -0
- package/dist/shell/execution-backend/agent.js +507 -0
- package/dist/shell/execution-backend/ci.js +15 -0
- package/dist/shell/execution-backend/container.js +69 -0
- package/dist/shell/execution-backend/envelopes.js +55 -0
- package/dist/shell/execution-backend/local.js +113 -0
- package/dist/shell/execution-backend/probes.js +175 -0
- package/dist/shell/execution-backend/registry.js +402 -0
- package/dist/shell/execution-backend/remote.js +128 -0
- package/dist/shell/execution-backend/types.js +11 -0
- package/dist/shell/feedback-cli.js +81 -0
- package/dist/shell/feedback-operations.js +48 -0
- package/dist/shell/fs-atomic.js +276 -0
- package/dist/shell/harness.js +98 -0
- package/dist/shell/ledger-cli.js +212 -0
- package/dist/shell/ledger-io.js +169 -0
- package/dist/shell/man-cli.js +89 -0
- package/dist/shell/metrics-cli.js +100 -0
- package/dist/shell/multi-agent-cli.js +1002 -0
- package/dist/shell/multi-agent-host.js +563 -0
- package/dist/shell/multi-agent-io.js +387 -0
- package/dist/{multi-agent-operator-ux.js → shell/multi-agent-operator-ux.js} +234 -191
- package/dist/shell/node-store.js +124 -0
- package/dist/{observability/format.js → shell/observability-format.js} +7 -1
- package/dist/{observability/intake.js → shell/observability-intake.js} +79 -56
- package/dist/{observability.js → shell/observability.js} +159 -332
- package/dist/{onramp.js → shell/onramp.js} +11 -0
- package/dist/{operator-ux/format.js → shell/operator-ux-text.js} +250 -239
- package/dist/shell/operator-ux.js +431 -0
- package/dist/shell/orchestrator.js +231 -0
- package/dist/shell/pipeline-cli.js +667 -0
- package/dist/shell/pipeline.js +217 -0
- package/dist/shell/reclamation-io.js +1366 -0
- package/dist/shell/registry-cli.js +344 -0
- package/dist/{remote-source.js → shell/remote-source.js} +2 -2
- package/dist/shell/report-cli.js +101 -0
- package/dist/shell/report-view-cli.js +117 -0
- package/dist/{orchestrator → shell}/report.js +289 -282
- package/dist/shell/reporter.js +62 -0
- package/dist/shell/run-export-cli.js +106 -0
- package/dist/shell/run-export.js +680 -0
- package/dist/shell/run-registry-io.js +1014 -0
- package/dist/shell/run-store.js +164 -0
- package/dist/{sandbox-profile.js → shell/sandbox-profile.js} +134 -95
- package/dist/{scheduler.js → shell/scheduler-io.js} +257 -48
- package/dist/shell/scheduling-io.js +321 -0
- package/dist/shell/state-cli.js +181 -0
- package/dist/shell/state-explosion-cli.js +197 -0
- package/dist/shell/telemetry-cli.js +85 -0
- package/dist/{telemetry-demo.js → shell/telemetry-demo.js} +149 -119
- package/dist/shell/telemetry-ledger-io.js +132 -0
- package/dist/{term.js → shell/term.js} +36 -46
- package/dist/shell/topology-io.js +361 -0
- package/dist/shell/trust-audit.js +472 -0
- package/dist/{multi-agent-trust.js → shell/trust-policy-io.js} +67 -205
- package/dist/shell/verifier.js +48 -0
- package/dist/shell/workbench-host.js +258 -0
- package/dist/shell/workbench-text.js +18 -0
- package/dist/shell/workbench.js +170 -0
- package/dist/shell/worker-cli.js +124 -0
- package/dist/shell/worker-isolation.js +852 -0
- package/dist/shell/workflow-app-loader.js +650 -0
- package/docs/agent-delegation-drive.7.md +4 -0
- package/docs/cli-mcp-parity.7.md +282 -219
- package/docs/contract-migration-tooling.7.md +4 -0
- package/docs/control-plane-scheduling.7.md +4 -0
- package/docs/durable-state-and-locking.7.md +4 -0
- package/docs/evidence-adoption-reasoning-chain.7.md +4 -0
- package/docs/execution-backends.7.md +4 -0
- package/docs/multi-agent-cli-mcp-surface.7.md +4 -0
- package/docs/multi-agent-eval-replay-harness.7.md +4 -0
- package/docs/multi-agent-operator-ux.7.md +4 -0
- package/docs/node-snapshot-diff-replay.7.md +4 -0
- package/docs/observability-cost-accounting.7.md +6 -1
- package/docs/project-index.md +137 -71
- package/docs/real-execution-backends.7.md +4 -0
- package/docs/release-and-migration.7.md +4 -0
- package/docs/release-tooling.7.md +4 -0
- package/docs/remote-source-review.7.md +4 -4
- package/docs/report-verifiable-bundle.7.md +1 -1
- package/docs/run-registry-control-plane.7.md +4 -0
- package/docs/run-retention-reclamation.7.md +25 -0
- package/docs/security-trust-hardening.7.md +3 -1
- package/docs/state-explosion-management.7.md +4 -0
- package/docs/team-collaboration.7.md +4 -0
- package/docs/web-desktop-workbench.7.md +15 -1
- package/manifest/plugin.manifest.json +1 -1
- package/manifest/source-context-profiles.json +9 -13
- package/package.json +1 -1
- package/scripts/agents/agent-adapter-core.js +22 -2
- package/scripts/agents/claude-p-agent.js +8 -3
- package/scripts/agents/cw-attest-wrap.js +2 -2
- package/scripts/agents/gemini-agent.js +5 -1
- package/scripts/agents/opencode-agent.js +5 -1
- package/scripts/bump-version.js +4 -3
- package/scripts/canonical-apps.js +4 -4
- package/scripts/dogfood-architecture-review.js +2 -3
- package/scripts/dogfood-release.js +3 -3
- package/scripts/gen-parity-doc.js +15 -2
- package/scripts/golden-path.js +4 -4
- package/scripts/onramp-check.js +1 -1
- package/scripts/parity-check.js +38 -21
- package/scripts/release-flow.js +2 -2
- package/scripts/sync-project-index.js +51 -27
- package/scripts/validate-run-state-schema.js +2 -2
- package/scripts/version-sync-check.js +30 -30
- package/dist/candidate-scoring.js +0 -729
- package/dist/capability-core.js +0 -1189
- package/dist/capability-registry.js +0 -885
- package/dist/cli/command-surface.js +0 -494
- package/dist/cli/format.js +0 -56
- package/dist/cli/handlers/audit.js +0 -82
- package/dist/cli/handlers/blackboard.js +0 -81
- package/dist/cli/handlers/candidate.js +0 -40
- package/dist/cli/handlers/clones.js +0 -34
- package/dist/cli/handlers/collaboration.js +0 -61
- package/dist/cli/handlers/eval.js +0 -40
- package/dist/cli/handlers/ledger.js +0 -169
- package/dist/cli/handlers/maintenance.js +0 -107
- package/dist/cli/handlers/multi-agent.js +0 -165
- package/dist/cli/handlers/node.js +0 -41
- package/dist/cli/handlers/operational.js +0 -155
- package/dist/cli/handlers/operator.js +0 -146
- package/dist/cli/handlers/registry.js +0 -68
- package/dist/cli/handlers/run.js +0 -153
- package/dist/cli/handlers/scheduling.js +0 -132
- package/dist/cli/handlers/workbench.js +0 -41
- package/dist/cli/handlers/worker.js +0 -45
- package/dist/cli/run-summary.js +0 -45
- package/dist/clones.js +0 -162
- package/dist/collaboration.js +0 -726
- package/dist/commit.js +0 -592
- package/dist/compare.js +0 -18
- package/dist/coordinator/classify.js +0 -45
- package/dist/coordinator/paths.js +0 -42
- package/dist/coordinator/util.js +0 -126
- package/dist/coordinator.js +0 -990
- package/dist/daemon.js +0 -44
- package/dist/dispatch.js +0 -250
- package/dist/doctor.js +0 -212
- package/dist/drive.js +0 -864
- package/dist/error-feedback.js +0 -419
- package/dist/evidence-grounding.js +0 -184
- package/dist/execution-backend/agent.js +0 -354
- package/dist/execution-backend/probes.js +0 -112
- package/dist/execution-backend/util.js +0 -47
- package/dist/execution-backend.js +0 -961
- package/dist/gates.js +0 -48
- package/dist/harness.js +0 -61
- package/dist/ledger.js +0 -313
- package/dist/loop-expansion.js +0 -60
- package/dist/mcp/tool-call.js +0 -470
- package/dist/mcp/tool-definitions.js +0 -1066
- package/dist/mcp-surface.js +0 -30
- package/dist/multi-agent/graph.js +0 -84
- package/dist/multi-agent/helpers.js +0 -141
- package/dist/multi-agent/ids.js +0 -20
- package/dist/multi-agent/paths.js +0 -22
- package/dist/multi-agent-eval/normalize.js +0 -51
- package/dist/multi-agent-eval.js +0 -678
- package/dist/multi-agent-host.js +0 -777
- package/dist/multi-agent.js +0 -984
- package/dist/node-projection.js +0 -59
- package/dist/node-snapshot.js +0 -260
- package/dist/operator-ux.js +0 -631
- package/dist/orchestrator/app-operations.js +0 -211
- package/dist/orchestrator/audit-operations.js +0 -182
- package/dist/orchestrator/candidate-operations.js +0 -117
- package/dist/orchestrator/cli-options.js +0 -294
- package/dist/orchestrator/collaboration-operations.js +0 -86
- package/dist/orchestrator/feedback-operations.js +0 -81
- package/dist/orchestrator/host-operations.js +0 -78
- package/dist/orchestrator/lifecycle-operations.js +0 -650
- package/dist/orchestrator/migration-operations.js +0 -44
- package/dist/orchestrator/multi-agent-operations.js +0 -362
- package/dist/orchestrator/topology-operations.js +0 -84
- package/dist/orchestrator.js +0 -925
- package/dist/pipeline-runner.js +0 -285
- package/dist/reclamation/hash.js +0 -72
- package/dist/reclamation.js +0 -812
- package/dist/reporter.js +0 -67
- package/dist/run-export.js +0 -815
- package/dist/run-registry/derive.js +0 -175
- package/dist/run-registry/format.js +0 -124
- package/dist/run-registry/gc.js +0 -251
- package/dist/run-registry/policy.js +0 -16
- package/dist/run-registry/queue.js +0 -115
- package/dist/run-registry.js +0 -850
- package/dist/run-state-schema.js +0 -68
- package/dist/scheduling.js +0 -184
- package/dist/state-explosion.js +0 -1014
- package/dist/state.js +0 -367
- package/dist/telemetry-ledger.js +0 -196
- package/dist/topology.js +0 -565
- package/dist/triggers.js +0 -184
- package/dist/trust-audit.js +0 -644
- package/dist/types/blackboard.js +0 -2
- package/dist/types/candidate.js +0 -2
- package/dist/types/collaboration.js +0 -2
- package/dist/types/core.js +0 -2
- package/dist/types/drive.js +0 -10
- package/dist/types/error-feedback.js +0 -2
- package/dist/types/evidence-reasoning.js +0 -2
- package/dist/types/execution-backend.js +0 -2
- package/dist/types/multi-agent.js +0 -2
- package/dist/types/observability.js +0 -2
- package/dist/types/pipeline.js +0 -2
- package/dist/types/reclamation.js +0 -8
- package/dist/types/report-bundle.js +0 -6
- package/dist/types/result.js +0 -2
- package/dist/types/run-registry.js +0 -2
- package/dist/types/run.js +0 -2
- package/dist/types/sandbox.js +0 -2
- package/dist/types/schedule.js +0 -2
- package/dist/types/state-node.js +0 -2
- package/dist/types/topology.js +0 -2
- package/dist/types/trust.js +0 -2
- package/dist/types/workbench.js +0 -2
- package/dist/types/worker.js +0 -2
- package/dist/types/workflow-app.js +0 -2
- package/dist/types.js +0 -44
- package/dist/util/fingerprint.js +0 -19
- package/dist/util/fingerprint.test.js +0 -27
- package/dist/verifier.js +0 -78
- package/dist/version.js +0 -8
- package/dist/workbench-host.js +0 -192
- package/dist/workbench.js +0 -192
- package/dist/worker-accept/acceptance.js +0 -114
- package/dist/worker-accept/blackboard-fanout.js +0 -80
- package/dist/worker-accept/blackboard-linkage.js +0 -19
- package/dist/worker-accept/context.js +0 -2
- package/dist/worker-accept/telemetry-ledger.js +0 -126
- package/dist/worker-accept/validation.js +0 -77
- package/dist/worker-accept/verifier-completion.js +0 -73
- package/dist/worker-isolation/helpers.js +0 -51
- package/dist/worker-isolation/paths.js +0 -46
- package/dist/worker-isolation.js +0 -656
- package/dist/workflow-api.js +0 -131
- /package/dist/{types → core/types}/boundary.js +0 -0
package/dist/daemon.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DesktopSchedulerDaemon = void 0;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
const scheduler_1 = require("./scheduler");
|
|
10
|
-
const state_1 = require("./state");
|
|
11
|
-
class DesktopSchedulerDaemon {
|
|
12
|
-
cwd;
|
|
13
|
-
intervalSeconds;
|
|
14
|
-
scheduler;
|
|
15
|
-
constructor(options = {}) {
|
|
16
|
-
this.cwd = node_path_1.default.resolve(String(options.cwd || process.cwd()));
|
|
17
|
-
this.intervalSeconds = Number(options.intervalSeconds || 60);
|
|
18
|
-
this.scheduler = new scheduler_1.Scheduler(this.cwd);
|
|
19
|
-
}
|
|
20
|
-
tick() {
|
|
21
|
-
const due = this.scheduler.due();
|
|
22
|
-
const checkedAt = new Date().toISOString();
|
|
23
|
-
const inboxPath = node_path_1.default.join(this.cwd, ".cw", "schedules", "due-inbox.json");
|
|
24
|
-
(0, state_1.writeJson)(inboxPath, {
|
|
25
|
-
schemaVersion: 1,
|
|
26
|
-
checkedAt,
|
|
27
|
-
due
|
|
28
|
-
});
|
|
29
|
-
return {
|
|
30
|
-
checkedAt,
|
|
31
|
-
dueCount: due.length,
|
|
32
|
-
dueIds: due.map((task) => task.id),
|
|
33
|
-
inboxPath
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
async run() {
|
|
37
|
-
node_fs_1.default.mkdirSync(node_path_1.default.join(this.cwd, ".cw", "schedules"), { recursive: true });
|
|
38
|
-
process.stdout.write(`${JSON.stringify(this.tick())}\n`);
|
|
39
|
-
setInterval(() => {
|
|
40
|
-
process.stdout.write(`${JSON.stringify(this.tick())}\n`);
|
|
41
|
-
}, Math.max(1, this.intervalSeconds) * 1000);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.DesktopSchedulerDaemon = DesktopSchedulerDaemon;
|
package/dist/dispatch.js
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.nextDispatchTasks = nextDispatchTasks;
|
|
7
|
-
exports.createDispatchManifest = createDispatchManifest;
|
|
8
|
-
exports.firstRunnablePhase = firstRunnablePhase;
|
|
9
|
-
exports.updatePhaseStatuses = updatePhaseStatuses;
|
|
10
|
-
exports.formatDispatchTask = formatDispatchTask;
|
|
11
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
12
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
-
const state_1 = require("./state");
|
|
14
|
-
const pipeline_contract_1 = require("./pipeline-contract");
|
|
15
|
-
const state_node_1 = require("./state-node");
|
|
16
|
-
const worker_isolation_1 = require("./worker-isolation");
|
|
17
|
-
const sandbox_profile_1 = require("./sandbox-profile");
|
|
18
|
-
const execution_backend_1 = require("./execution-backend");
|
|
19
|
-
const multi_agent_1 = require("./multi-agent");
|
|
20
|
-
function nextDispatchTasks(run, limit) {
|
|
21
|
-
const runnablePhase = firstRunnablePhase(run);
|
|
22
|
-
if (!runnablePhase)
|
|
23
|
-
return [];
|
|
24
|
-
const max = Number(limit || run.workflow.limits.maxConcurrentAgents || 4);
|
|
25
|
-
const runnableTaskIds = new Set(runnablePhase.taskIds);
|
|
26
|
-
return run.tasks
|
|
27
|
-
.filter((task) => task.status === "pending" && runnableTaskIds.has(task.id))
|
|
28
|
-
.slice(0, max)
|
|
29
|
-
.map(formatDispatchTask);
|
|
30
|
-
}
|
|
31
|
-
function createDispatchManifest(run, limit, options = {}) {
|
|
32
|
-
const requestedSandboxProfileId = options.sandboxProfileId || options.sandbox;
|
|
33
|
-
const sandboxProfileId = String(requestedSandboxProfileId || sandbox_profile_1.DEFAULT_SANDBOX_PROFILE_ID);
|
|
34
|
-
(0, sandbox_profile_1.resolveSandboxProfileById)(sandboxProfileId, (0, sandbox_profile_1.sandboxContextForValidation)(run.cwd));
|
|
35
|
-
// H7: if the requested profile is a CUSTOM profile loaded from a FILE (non-bundled,
|
|
36
|
-
// existing file), persist its DEFINITION on run.customSandboxProfiles keyed by the
|
|
37
|
-
// definition's logical id. This makes the custom profile durable with run state so a
|
|
38
|
-
// worker boundary can re-resolve it by logical id after a scope snapshot is lost
|
|
39
|
-
// (re-resolving against the worker context, not the dispatch-time file path).
|
|
40
|
-
persistCustomSandboxProfile(run, sandboxProfileId);
|
|
41
|
-
// Resolve the execution backend once (mechanism vs policy): the kernel records
|
|
42
|
-
// WHICH backend was selected; it never branches on which one. Defaults to node
|
|
43
|
-
// (behavior-preserving) when no `--backend` flag / CW_BACKEND env is set.
|
|
44
|
-
const backendSelection = (0, execution_backend_1.resolveBackendSelection)(options.backendId);
|
|
45
|
-
const tasks = nextDispatchTasks(run, limit);
|
|
46
|
-
if (!tasks.length) {
|
|
47
|
-
return {
|
|
48
|
-
schemaVersion: 1,
|
|
49
|
-
runId: run.id,
|
|
50
|
-
dispatchId: null,
|
|
51
|
-
tasks: [],
|
|
52
|
-
manifestPath: null,
|
|
53
|
-
sandboxProfileId,
|
|
54
|
-
backendId: backendSelection.backendId,
|
|
55
|
-
backendSelection
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
const dispatchId = createDispatchId(run);
|
|
59
|
-
const manifestPath = node_path_1.default.join(run.paths.dispatchesDir, `${dispatchId}.json`);
|
|
60
|
-
node_fs_1.default.mkdirSync(run.paths.dispatchesDir, { recursive: true });
|
|
61
|
-
const taskIds = new Set(tasks.map((task) => task.id));
|
|
62
|
-
const createdAt = new Date().toISOString();
|
|
63
|
-
const selectedSandboxProfileIds = new Set();
|
|
64
|
-
let sandboxPolicy;
|
|
65
|
-
for (const task of run.tasks) {
|
|
66
|
-
if (taskIds.has(task.id)) {
|
|
67
|
-
const taskSandboxProfileId = String(requestedSandboxProfileId || task.sandboxProfileId || sandbox_profile_1.DEFAULT_SANDBOX_PROFILE_ID);
|
|
68
|
-
selectedSandboxProfileIds.add(taskSandboxProfileId);
|
|
69
|
-
task.status = "running";
|
|
70
|
-
task.loopStage = "act";
|
|
71
|
-
task.dispatchId = dispatchId;
|
|
72
|
-
task.dispatchedAt = createdAt;
|
|
73
|
-
const scope = (0, worker_isolation_1.allocateWorkerScope)(run, task, {
|
|
74
|
-
dispatchId,
|
|
75
|
-
sandboxProfileId: taskSandboxProfileId,
|
|
76
|
-
backendSelection,
|
|
77
|
-
status: "running",
|
|
78
|
-
persist: false,
|
|
79
|
-
metadata: { dispatchId, phase: task.phase }
|
|
80
|
-
});
|
|
81
|
-
sandboxPolicy = sandboxPolicy || scope.sandboxPolicy;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
const selectedRunTasks = run.tasks.filter((task) => taskIds.has(task.id));
|
|
85
|
-
const multiAgentAttachment = (0, multi_agent_1.attachDispatchToMultiAgent)(run, {
|
|
86
|
-
multiAgentRunId: options.multiAgentRunId,
|
|
87
|
-
groupId: options.multiAgentGroupId,
|
|
88
|
-
roleId: options.multiAgentRoleId,
|
|
89
|
-
fanoutId: options.multiAgentFanoutId,
|
|
90
|
-
dispatchId,
|
|
91
|
-
tasks: selectedRunTasks,
|
|
92
|
-
sandboxProfileId: selectedSandboxProfileIds.size === 1 ? [...selectedSandboxProfileIds][0] : "mixed",
|
|
93
|
-
concurrencyLimit: limit
|
|
94
|
-
});
|
|
95
|
-
for (const task of selectedRunTasks) {
|
|
96
|
-
const worker = task.workerId ? (0, worker_isolation_1.syncWorkerScopeFromTask)(run, task.workerId) : undefined;
|
|
97
|
-
if (worker)
|
|
98
|
-
(0, worker_isolation_1.writeWorkerManifest)(run, worker);
|
|
99
|
-
}
|
|
100
|
-
const manifest = {
|
|
101
|
-
schemaVersion: 1,
|
|
102
|
-
runId: run.id,
|
|
103
|
-
dispatchId,
|
|
104
|
-
createdAt,
|
|
105
|
-
phase: tasks[0].phase,
|
|
106
|
-
instructions: "Spawn one worker per task when the user explicitly authorized agent/parallel/background work. Save each final summary as Markdown and record it with `cw.js result <run-id> <task-id> <file>`.",
|
|
107
|
-
tasks: selectedRunTasks.map(formatDispatchTask),
|
|
108
|
-
manifestPath,
|
|
109
|
-
workerIndexPath: run.paths.workersDir ? node_path_1.default.join(run.paths.workersDir, "index.json") : undefined,
|
|
110
|
-
sandboxProfileId: selectedSandboxProfileIds.size === 1 ? [...selectedSandboxProfileIds][0] : "mixed",
|
|
111
|
-
sandboxPolicy: selectedSandboxProfileIds.size === 1 ? sandboxPolicy : undefined,
|
|
112
|
-
backendId: backendSelection.backendId,
|
|
113
|
-
backendSelection,
|
|
114
|
-
backendAttestation: selectedRunTasks.find((task) => task.backendAttestation)?.backendAttestation,
|
|
115
|
-
multiAgent: multiAgentAttachment.multiAgent
|
|
116
|
-
? {
|
|
117
|
-
...multiAgentAttachment.multiAgent,
|
|
118
|
-
membershipIds: multiAgentAttachment.membershipIds
|
|
119
|
-
}
|
|
120
|
-
: undefined
|
|
121
|
-
};
|
|
122
|
-
const dispatchNode = (0, state_node_1.appendRunNode)(run, (0, state_node_1.createStateNode)({
|
|
123
|
-
id: `${run.id}:dispatch:${dispatchId}`,
|
|
124
|
-
kind: "dispatch",
|
|
125
|
-
status: "running",
|
|
126
|
-
loopStage: "act",
|
|
127
|
-
inputs: { taskIds: tasks.map((task) => task.id), phase: manifest.phase, sandboxProfileId: manifest.sandboxProfileId },
|
|
128
|
-
outputs: { dispatchId, sandboxProfileId: manifest.sandboxProfileId },
|
|
129
|
-
artifacts: [{ id: "dispatch", kind: "json", path: manifestPath }],
|
|
130
|
-
parents: tasks.map((task) => `${run.id}:task:${task.id}`),
|
|
131
|
-
contractId: pipeline_contract_1.DEFAULT_PIPELINE_CONTRACT_ID,
|
|
132
|
-
metadata: { sandboxProfileId: manifest.sandboxProfileId, sandboxPolicy: manifest.sandboxPolicy }
|
|
133
|
-
}));
|
|
134
|
-
manifest.stateNodeId = dispatchNode.id;
|
|
135
|
-
for (const task of run.tasks) {
|
|
136
|
-
if (!taskIds.has(task.id) || !task.stateNodeId)
|
|
137
|
-
continue;
|
|
138
|
-
const node = run.nodes?.find((candidate) => candidate.id === task.stateNodeId);
|
|
139
|
-
if (node && node.status === "pending") {
|
|
140
|
-
(0, state_node_1.appendRunNode)(run, (0, state_node_1.transitionStateNode)(node, { status: "running", loopStage: "act" }));
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
run.dispatches.push({
|
|
144
|
-
id: dispatchId,
|
|
145
|
-
phase: manifest.phase || "",
|
|
146
|
-
taskIds: tasks.map((task) => task.id),
|
|
147
|
-
manifestPath,
|
|
148
|
-
createdAt,
|
|
149
|
-
stateNodeId: dispatchNode.id,
|
|
150
|
-
workerIds: selectedRunTasks.filter((task) => task.workerId).map((task) => String(task.workerId)),
|
|
151
|
-
sandboxProfileId: manifest.sandboxProfileId,
|
|
152
|
-
backendId: backendSelection.backendId,
|
|
153
|
-
multiAgent: manifest.multiAgent
|
|
154
|
-
});
|
|
155
|
-
updatePhaseStatuses(run);
|
|
156
|
-
(0, state_1.writeJson)(manifestPath, manifest);
|
|
157
|
-
return manifest;
|
|
158
|
-
}
|
|
159
|
-
function firstRunnablePhase(run) {
|
|
160
|
-
for (const phase of run.phases) {
|
|
161
|
-
const phaseTasks = run.tasks.filter((task) => phase.taskIds.includes(task.id));
|
|
162
|
-
if (phaseTasks.some((task) => task.status === "running"))
|
|
163
|
-
return phase;
|
|
164
|
-
if (phaseTasks.some((task) => task.status === "pending"))
|
|
165
|
-
return phase;
|
|
166
|
-
if (!phaseTasks.every((task) => task.status === "completed"))
|
|
167
|
-
return null;
|
|
168
|
-
}
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
function updatePhaseStatuses(run) {
|
|
172
|
-
for (const phase of run.phases) {
|
|
173
|
-
const phaseTasks = run.tasks.filter((task) => phase.taskIds.includes(task.id));
|
|
174
|
-
if (phaseTasks.every((task) => task.status === "completed")) {
|
|
175
|
-
phase.status = "completed";
|
|
176
|
-
}
|
|
177
|
-
else if (phaseTasks.some((task) => task.status === "running" || task.status === "completed")) {
|
|
178
|
-
phase.status = "running";
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
phase.status = "pending";
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
function formatDispatchTask(task) {
|
|
186
|
-
return {
|
|
187
|
-
id: task.id,
|
|
188
|
-
kind: task.kind,
|
|
189
|
-
phase: task.phase,
|
|
190
|
-
status: task.status,
|
|
191
|
-
taskPath: task.taskPath,
|
|
192
|
-
prompt: task.prompt,
|
|
193
|
-
workerId: task.workerId,
|
|
194
|
-
workerManifestPath: task.workerManifestPath,
|
|
195
|
-
workerDir: task.workerManifestPath ? node_path_1.default.dirname(task.workerManifestPath) : undefined,
|
|
196
|
-
workerResultPath: task.workerId && task.workerManifestPath ? node_path_1.default.join(node_path_1.default.dirname(task.workerManifestPath), "result.md") : undefined,
|
|
197
|
-
sandboxProfileId: task.sandboxProfileId,
|
|
198
|
-
sandboxPolicy: task.sandboxPolicy,
|
|
199
|
-
backendId: task.backendId,
|
|
200
|
-
backendAttestation: task.backendAttestation,
|
|
201
|
-
multiAgent: task.multiAgent
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
// Deterministic dispatch id (replay-determinism self-audit): the wall-clock stamp
|
|
205
|
-
// is an edge timestamp for human readability. Set CW_DETERMINISTIC_RUN_IDS=1 to
|
|
206
|
-
// use a content-hash-based id without wall-clock, so re-running the same workflow
|
|
207
|
-
// yields byte-identical dispatch ids. The suffix is a per-run sequence, so each
|
|
208
|
-
// dispatch still gets a distinct, monotonically increasing id.
|
|
209
|
-
function createDispatchId(run) {
|
|
210
|
-
const stamp = new Date().toISOString().replace(/[-:]/g, "").replace(/\..+/, "Z");
|
|
211
|
-
const seq = (run.dispatches?.length || 0) + 1;
|
|
212
|
-
if (/^(1|true|yes|on)$/i.test(process.env.CW_DETERMINISTIC_RUN_IDS || "")) {
|
|
213
|
-
return `dispatch-${String(seq).padStart(4, "0")}`;
|
|
214
|
-
}
|
|
215
|
-
return `dispatch-${stamp}-${String(seq).padStart(4, "0")}`;
|
|
216
|
-
}
|
|
217
|
-
// H7: persist a CUSTOM sandbox profile DEFINITION (loaded from a FILE at dispatch)
|
|
218
|
-
// onto run.customSandboxProfiles, keyed by the definition's logical id. Only fires
|
|
219
|
-
// for a non-bundled id that resolves to a readable, valid profile file. The
|
|
220
|
-
// resolveSandboxProfileById call above has already validated the file (it throws on
|
|
221
|
-
// invalid), so this re-parses only to recover the raw DEFINITION — we store the
|
|
222
|
-
// definition (not a resolved policy) so worker-specific path tokens re-bind to the
|
|
223
|
-
// correct worker context on every later re-resolve. Bundled ids and unknown ids are
|
|
224
|
-
// left untouched, so this never shadows a bundled profile or masks a fail-closed.
|
|
225
|
-
function persistCustomSandboxProfile(run, requested) {
|
|
226
|
-
if (!requested || (0, sandbox_profile_1.isBundledSandboxProfileId)(requested))
|
|
227
|
-
return;
|
|
228
|
-
const absolute = node_path_1.default.resolve(requested);
|
|
229
|
-
if (!node_fs_1.default.existsSync(absolute) || !node_fs_1.default.statSync(absolute).isFile())
|
|
230
|
-
return;
|
|
231
|
-
const validation = (0, sandbox_profile_1.validateSandboxProfileFile)(requested, (0, sandbox_profile_1.sandboxContextForValidation)(run.cwd));
|
|
232
|
-
if (!validation.valid || !validation.profile)
|
|
233
|
-
return;
|
|
234
|
-
let definition;
|
|
235
|
-
try {
|
|
236
|
-
definition = JSON.parse(node_fs_1.default.readFileSync(absolute, "utf8"));
|
|
237
|
-
}
|
|
238
|
-
catch {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
if (!definition || typeof definition !== "object" || typeof definition.id !== "string" || !definition.id)
|
|
242
|
-
return;
|
|
243
|
-
run.customSandboxProfiles = run.customSandboxProfiles || {};
|
|
244
|
-
const previous = run.customSandboxProfiles[definition.id];
|
|
245
|
-
if (previous && JSON.stringify(previous) !== JSON.stringify(definition)) {
|
|
246
|
-
throw new Error(`Sandbox profile id collision: "${definition.id}" is already defined by a different custom profile ` +
|
|
247
|
-
`(source: ${absolute}). Use a unique id in each custom profile file.`);
|
|
248
|
-
}
|
|
249
|
-
run.customSandboxProfiles[definition.id] = definition;
|
|
250
|
-
}
|
package/dist/doctor.js
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.runDoctor = runDoctor;
|
|
7
|
-
exports.formatDoctorReport = formatDoctorReport;
|
|
8
|
-
exports.formatDoctorFixes = formatDoctorFixes;
|
|
9
|
-
// `cw doctor` — environment diagnostics, in the spirit of `brew doctor`.
|
|
10
|
-
//
|
|
11
|
-
// Homebrew's `doctor` turned "something is subtly wrong with your setup" into a
|
|
12
|
-
// proactive, named list of problems each paired with a concrete fix. We borrow
|
|
13
|
-
// that idea: instead of letting a missing agent / old Node / unwritable state
|
|
14
|
-
// surface as a confusing mid-run failure, `cw doctor` probes the host up front
|
|
15
|
-
// and prints WHAT is wrong and WHAT TO DO about it.
|
|
16
|
-
//
|
|
17
|
-
// Discipline:
|
|
18
|
-
// - READ-ONLY. Probes versions, $PATH, and the WRITABILITY of the nearest
|
|
19
|
-
// existing ancestor dir (via access(2)) — it never creates `.cw/` or $CW_HOME
|
|
20
|
-
// as a side effect, so running `doctor` changes nothing on disk.
|
|
21
|
-
// - FAIL CLOSED. Any `fail` check ⇒ `ok:false` ⇒ the CLI exits non-zero. A
|
|
22
|
-
// `warn` (e.g. no agent yet — demo/preview still work) does not fail.
|
|
23
|
-
// - TWO RENDERINGS. Human text by default; a stable `--json` payload for scripts.
|
|
24
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
25
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
26
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
27
|
-
const node_child_process_1 = require("node:child_process");
|
|
28
|
-
const agent_config_1 = require("./agent-config");
|
|
29
|
-
const onramp_1 = require("./onramp");
|
|
30
|
-
const term_1 = require("./term");
|
|
31
|
-
/** Resolve a bare binary name against $PATH (or accept an explicit path). Returns
|
|
32
|
-
* the resolved path, or undefined when not found. No spawning. */
|
|
33
|
-
function whichBinary(bin, env) {
|
|
34
|
-
if (bin.includes("/") || bin.includes("\\")) {
|
|
35
|
-
try {
|
|
36
|
-
return node_fs_1.default.statSync(bin).isFile() ? bin : undefined;
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const dirs = (env.PATH || "").split(node_path_1.default.delimiter).filter(Boolean);
|
|
43
|
-
const exts = process.platform === "win32" ? (env.PATHEXT || ".EXE;.CMD;.BAT").split(";") : [""];
|
|
44
|
-
for (const dir of dirs) {
|
|
45
|
-
for (const ext of exts) {
|
|
46
|
-
const candidate = node_path_1.default.join(dir, bin + ext);
|
|
47
|
-
try {
|
|
48
|
-
if (node_fs_1.default.statSync(candidate).isFile())
|
|
49
|
-
return candidate;
|
|
50
|
-
}
|
|
51
|
-
catch { /* keep looking */ }
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
/** True when `target` could be created/written: walk up to the nearest EXISTING
|
|
57
|
-
* ancestor and require it to be a writable DIRECTORY. (A file in the path is not
|
|
58
|
-
* writable-as-a-dir even though access(2) W_OK on the file itself would pass.)
|
|
59
|
-
* Does NOT create anything — a diagnostic must not have side effects. */
|
|
60
|
-
function dirWritable(target) {
|
|
61
|
-
let dir = node_path_1.default.resolve(target);
|
|
62
|
-
for (;;) {
|
|
63
|
-
let stat;
|
|
64
|
-
try {
|
|
65
|
-
stat = node_fs_1.default.statSync(dir);
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
const parent = node_path_1.default.dirname(dir);
|
|
69
|
-
if (parent === dir)
|
|
70
|
-
return false;
|
|
71
|
-
dir = parent;
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
if (!stat.isDirectory())
|
|
75
|
-
return false; // an existing file blocks mkdir beneath it
|
|
76
|
-
try {
|
|
77
|
-
node_fs_1.default.accessSync(dir, node_fs_1.default.constants.W_OK);
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
catch {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function runDoctor(args = {}, env = process.env, cwd = process.cwd()) {
|
|
86
|
-
const checks = [];
|
|
87
|
-
// 1. Node runtime — the one hard prerequisite (README: v18+).
|
|
88
|
-
const major = Number((process.version.match(/^v(\d+)/) || [])[1]);
|
|
89
|
-
checks.push(Number.isFinite(major) && major >= 18
|
|
90
|
-
? { name: "node", status: "ok", detail: `Node ${process.version} (>= 18).` }
|
|
91
|
-
: { name: "node", status: "fail", detail: `Node ${process.version} is below the required v18.`, fix: "Install Node.js 18+ (e.g. `brew install node`, or https://nodejs.org)." });
|
|
92
|
-
// 2. Agent backend — CW delegates execution; without one, real runs park.
|
|
93
|
-
const cfg = (0, agent_config_1.resolveAgentConfig)(args, env);
|
|
94
|
-
if (cfg.source === "auto") {
|
|
95
|
-
const vendor = (cfg.model && cfg.model.startsWith("builtin:")) ? cfg.model.slice("builtin:".length) : "auto";
|
|
96
|
-
checks.push({
|
|
97
|
-
name: "agent",
|
|
98
|
-
status: "ok",
|
|
99
|
-
detail: `Agent auto-detected: ${vendor}. Set CW_AGENT_COMMAND or --agent-command to override.`
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
else if (cfg.source === "none") {
|
|
103
|
-
checks.push({
|
|
104
|
-
name: "agent",
|
|
105
|
-
status: "warn",
|
|
106
|
-
detail: "No agent backend configured — `demo` and `--preview` work, but a real run reports status: blocked.",
|
|
107
|
-
fix: 'Pass --agent-command "claude -p", set $CW_AGENT_COMMAND, or use --agent-command builtin:claude.'
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
const binToken = cfg.command ? String(cfg.command).split(/\s+/)[0] : undefined;
|
|
112
|
-
checks.push({
|
|
113
|
-
name: "agent",
|
|
114
|
-
status: "ok",
|
|
115
|
-
detail: `Agent configured from ${cfg.source}${binToken ? `: ${binToken}` : cfg.endpoint ? " (HTTP endpoint)" : ""}.`
|
|
116
|
-
});
|
|
117
|
-
// 2b. If it is a command agent, is the binary actually on PATH?
|
|
118
|
-
if (binToken) {
|
|
119
|
-
const resolved = whichBinary(binToken, env);
|
|
120
|
-
checks.push(resolved
|
|
121
|
-
? { name: "agent-binary", status: "ok", detail: `Agent binary "${binToken}" found at ${resolved}.` }
|
|
122
|
-
: { name: "agent-binary", status: "warn", detail: `Configured agent binary "${binToken}" is not on $PATH.`, fix: `Install "${binToken}", or correct --agent-command / $CW_AGENT_COMMAND.` });
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// 3. git — only needed for commit provenance (git HEAD); a warn, not a hard fail.
|
|
126
|
-
const git = (0, node_child_process_1.spawnSync)("git", ["--version"], { encoding: "utf8", timeout: 5000 });
|
|
127
|
-
checks.push(!git.error && git.status === 0
|
|
128
|
-
? { name: "git", status: "ok", detail: (String(git.stdout || "git").trim()) + "." }
|
|
129
|
-
: { name: "git", status: "warn", detail: "git is not available — commit provenance (git HEAD) is recorded as absent.", fix: "Install git (e.g. `brew install git`) if you want commit provenance." });
|
|
130
|
-
// 4. Home registry — the cross-repo run index lives here; must be writable.
|
|
131
|
-
const home = env.CW_HOME && String(env.CW_HOME).trim()
|
|
132
|
-
? node_path_1.default.resolve(String(env.CW_HOME))
|
|
133
|
-
: node_path_1.default.join(node_os_1.default.homedir(), ".local", "state", "cool-workflow");
|
|
134
|
-
checks.push(dirWritable(home)
|
|
135
|
-
? { name: "home-registry", status: "ok", detail: `Home registry location is writable (${home}).` }
|
|
136
|
-
: { name: "home-registry", status: "fail", detail: `Home registry location is not writable: ${home}`, fix: "Set $CW_HOME to a writable directory, or fix the permissions." });
|
|
137
|
-
// 5. Working-dir state — per-repo runs land under <cwd>/.cw.
|
|
138
|
-
const cwState = node_path_1.default.join(node_path_1.default.resolve(cwd), ".cw");
|
|
139
|
-
checks.push(dirWritable(cwState)
|
|
140
|
-
? { name: "repo-state", status: "ok", detail: `Run state location is writable (${cwState}).` }
|
|
141
|
-
: { name: "repo-state", status: "warn", detail: `Cannot write run state under ${cwState}.`, fix: "Run from a writable working directory, or pass --cwd PATH." });
|
|
142
|
-
const fails = checks.filter((c) => c.status === "fail").length;
|
|
143
|
-
const warns = checks.filter((c) => c.status === "warn").length;
|
|
144
|
-
const ok = fails === 0;
|
|
145
|
-
const summary = ok
|
|
146
|
-
? warns === 0
|
|
147
|
-
? "ready — all checks passed"
|
|
148
|
-
: `ready, with ${warns} warning${warns === 1 ? "" : "s"}`
|
|
149
|
-
: `${fails} blocking problem${fails === 1 ? "" : "s"} found`;
|
|
150
|
-
return {
|
|
151
|
-
schemaVersion: 1,
|
|
152
|
-
ok,
|
|
153
|
-
checks,
|
|
154
|
-
summary,
|
|
155
|
-
...((0, onramp_1.optionEnabled)(args.onramp)
|
|
156
|
-
? { onramp: (0, onramp_1.buildDoctorOnramp)({ cwd, env, changedFrom: typeof args["changed-from"] === "string" ? args["changed-from"] : undefined }) }
|
|
157
|
-
: {})
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
/** Human rendering (TTY/default). `--json` callers use the report object directly. */
|
|
161
|
-
function formatDoctorReport(report) {
|
|
162
|
-
const lines = [(0, term_1.bold)("cw doctor")];
|
|
163
|
-
for (const check of report.checks) {
|
|
164
|
-
lines.push(` ${(0, term_1.doctorGlyph)(check.status)} ${check.name}: ${check.detail}`);
|
|
165
|
-
if (check.fix && check.status !== "ok")
|
|
166
|
-
lines.push(` fix: ${check.fix}`);
|
|
167
|
-
}
|
|
168
|
-
lines.push("");
|
|
169
|
-
const summaryGlyph = report.ok ? (0, term_1.green)("✓") : (0, term_1.red)("✗");
|
|
170
|
-
lines.push(`${summaryGlyph} ${report.summary}`);
|
|
171
|
-
if (report.onramp) {
|
|
172
|
-
lines.push("");
|
|
173
|
-
lines.push("Quick start (3 steps):");
|
|
174
|
-
lines.push(" 1. cw demo tamper — prove trust checks work (30s)");
|
|
175
|
-
lines.push(" 2. cw demo bundle — prove portable bundles (30s)");
|
|
176
|
-
lines.push(' 3. cw -q "what risks?" — your first real report (needs an agent)');
|
|
177
|
-
lines.push(' cw quickstart research-synthesis --repo <folder> --question "..." — cited report over a docs/papers folder, not only code');
|
|
178
|
-
lines.push("");
|
|
179
|
-
lines.push("Onramp");
|
|
180
|
-
lines.push(` ${report.onramp.summary}`);
|
|
181
|
-
if (report.onramp.recommendedChecks) {
|
|
182
|
-
lines.push("");
|
|
183
|
-
lines.push(" Recommended Checks");
|
|
184
|
-
for (const command of report.onramp.recommendedChecks.commands)
|
|
185
|
-
lines.push(` - ${command}`);
|
|
186
|
-
}
|
|
187
|
-
if (report.onramp.contract && !report.onramp.contract.ok) {
|
|
188
|
-
lines.push("");
|
|
189
|
-
lines.push(" Contract Issues");
|
|
190
|
-
for (const issue of report.onramp.contract.issues) {
|
|
191
|
-
lines.push(` - ${issue.code}: ${issue.detail}`);
|
|
192
|
-
lines.push(` fix: ${issue.fix}`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
for (const section of report.onramp.sections) {
|
|
196
|
-
lines.push("");
|
|
197
|
-
lines.push(` ${section.title}: ${section.summary}`);
|
|
198
|
-
for (const action of section.actions) {
|
|
199
|
-
lines.push(` - ${action.command}`);
|
|
200
|
-
lines.push(` ${action.reason}`);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return lines.join("\n");
|
|
205
|
-
}
|
|
206
|
-
/** `--fix` rendering: consolidates all fix strings into an actionable block. */
|
|
207
|
-
function formatDoctorFixes(report) {
|
|
208
|
-
const fixes = report.checks.filter((c) => c.fix && c.status !== "ok").map((c) => c.fix);
|
|
209
|
-
if (!fixes.length)
|
|
210
|
-
return "No fixes needed.";
|
|
211
|
-
return [(0, term_1.bold)("Fix Commands"), ...fixes.map((f, i) => ` ${i + 1}. ${f}`), ""].join("\n");
|
|
212
|
-
}
|