@interf/compiler 0.5.1 → 0.6.3
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/README.md +160 -201
- package/builtin-workflows/interf/README.md +22 -10
- package/builtin-workflows/interf/compile/stages/shape/SKILL.md +8 -5
- package/builtin-workflows/interf/compile/stages/structure/SKILL.md +3 -0
- package/builtin-workflows/interf/compile/stages/summarize/SKILL.md +18 -2
- package/builtin-workflows/interf/improve/SKILL.md +4 -4
- package/builtin-workflows/interf/use/query/SKILL.md +1 -1
- package/builtin-workflows/interf/workflow.json +19 -5
- package/builtin-workflows/interf/{compiled.schema.json → workflow.schema.json} +10 -3
- package/dist/bin.js +2 -28
- package/dist/{commands → cli/commands}/check-draft.d.ts +2 -2
- package/dist/{commands → cli/commands}/check-draft.js +13 -13
- package/dist/{commands → cli/commands}/compile-controller.d.ts +3 -3
- package/dist/{commands → cli/commands}/compile-controller.js +39 -44
- package/dist/cli/commands/compile.d.ts +33 -0
- package/dist/{commands → cli/commands}/compile.js +107 -33
- package/dist/{commands → cli/commands}/compiled-flow.d.ts +3 -4
- package/dist/{commands → cli/commands}/compiled-flow.js +9 -14
- package/dist/{commands → cli/commands}/create-workflow-wizard.d.ts +20 -2
- package/dist/cli/commands/create-workflow-wizard.js +288 -0
- package/dist/{commands → cli/commands}/create.d.ts +2 -2
- package/dist/cli/commands/create.js +166 -0
- package/dist/cli/commands/dataset-selection.d.ts +6 -0
- package/dist/cli/commands/dataset-selection.js +11 -0
- package/dist/{commands → cli/commands}/default.js +5 -5
- package/dist/{commands → cli/commands}/doctor.js +12 -13
- package/dist/{commands → cli/commands}/executor-flow.d.ts +2 -2
- package/dist/{commands → cli/commands}/executor-flow.js +17 -17
- package/dist/cli/commands/init.d.ts +11 -0
- package/dist/{commands → cli/commands}/init.js +202 -109
- package/dist/{commands → cli/commands}/list.js +9 -6
- package/dist/{commands → cli/commands}/reset.js +5 -5
- package/dist/{commands → cli/commands}/source-config-wizard.d.ts +10 -5
- package/dist/{commands → cli/commands}/source-config-wizard.js +202 -95
- package/dist/{commands → cli/commands}/status.js +20 -11
- package/dist/{commands → cli/commands}/test-flow.d.ts +13 -4
- package/dist/{commands → cli/commands}/test-flow.js +30 -26
- package/dist/cli/commands/test.d.ts +14 -0
- package/dist/{commands → cli/commands}/test.js +48 -40
- package/dist/{commands → cli/commands}/verify.js +4 -4
- package/dist/cli/index.d.ts +21 -0
- package/dist/cli/index.js +33 -0
- package/dist/index.d.ts +22 -11
- package/dist/index.js +15 -6
- package/dist/lib/agent-args.d.ts +1 -3
- package/dist/lib/agent-args.js +1 -42
- package/dist/lib/agent-constants.d.ts +1 -5
- package/dist/lib/agent-constants.js +1 -28
- package/dist/lib/agent-detection.d.ts +1 -7
- package/dist/lib/agent-detection.js +1 -65
- package/dist/lib/agent-execution.d.ts +1 -2
- package/dist/lib/agent-execution.js +1 -242
- package/dist/lib/agent-logs.d.ts +1 -2
- package/dist/lib/agent-logs.js +1 -17
- package/dist/lib/agent-preflight.d.ts +1 -7
- package/dist/lib/agent-preflight.js +1 -76
- package/dist/lib/agent-render.d.ts +1 -8
- package/dist/lib/agent-render.js +1 -218
- package/dist/lib/agent-shells.d.ts +1 -44
- package/dist/lib/agent-shells.js +1 -847
- package/dist/lib/agent-status.d.ts +1 -3
- package/dist/lib/agent-status.js +1 -58
- package/dist/lib/agent-types.d.ts +1 -30
- package/dist/lib/agent-types.js +1 -1
- package/dist/lib/agents.d.ts +1 -6
- package/dist/lib/agents.js +1 -5
- package/dist/lib/builtin-compiled-workflow.d.ts +1 -129
- package/dist/lib/builtin-compiled-workflow.js +1 -153
- package/dist/lib/compiled-compile.d.ts +1 -52
- package/dist/lib/compiled-compile.js +1 -274
- package/dist/lib/compiled-paths.d.ts +1 -39
- package/dist/lib/compiled-paths.js +3 -103
- package/dist/lib/compiled-raw.d.ts +1 -49
- package/dist/lib/compiled-raw.js +3 -102
- package/dist/lib/compiled-reset.d.ts +1 -1
- package/dist/lib/compiled-reset.js +3 -44
- package/dist/lib/compiled-schema.d.ts +1 -27
- package/dist/lib/compiled-schema.js +1 -110
- package/dist/lib/discovery.d.ts +1 -1
- package/dist/lib/discovery.js +2 -2
- package/dist/lib/execution-profile.d.ts +1 -17
- package/dist/lib/execution-profile.js +1 -84
- package/dist/lib/executors.d.ts +1 -32
- package/dist/lib/executors.js +1 -43
- package/dist/lib/interf-bootstrap.d.ts +1 -3
- package/dist/lib/interf-bootstrap.js +3 -18
- package/dist/lib/interf-detect.d.ts +1 -33
- package/dist/lib/interf-detect.js +3 -176
- package/dist/lib/interf-scaffold.d.ts +1 -2
- package/dist/lib/interf-scaffold.js +3 -121
- package/dist/lib/interf-workflow-package.d.ts +1 -20
- package/dist/lib/interf-workflow-package.js +1 -276
- package/dist/lib/interf.d.ts +1 -5
- package/dist/lib/interf.js +3 -4
- package/dist/lib/local-workflows.d.ts +1 -53
- package/dist/lib/local-workflows.js +1 -399
- package/dist/lib/package-root.d.ts +1 -0
- package/dist/lib/package-root.js +1 -0
- package/dist/lib/project-paths.d.ts +1 -11
- package/dist/lib/project-paths.js +3 -32
- package/dist/lib/runtime-acceptance.d.ts +1 -9
- package/dist/lib/runtime-acceptance.js +1 -257
- package/dist/lib/runtime-contracts.d.ts +1 -2
- package/dist/lib/runtime-contracts.js +1 -47
- package/dist/lib/runtime-inventory.d.ts +1 -7
- package/dist/lib/runtime-inventory.js +1 -29
- package/dist/lib/runtime-paths.d.ts +1 -7
- package/dist/lib/runtime-paths.js +1 -23
- package/dist/lib/runtime-prompt.d.ts +1 -2
- package/dist/lib/runtime-prompt.js +1 -46
- package/dist/lib/runtime-reconcile.d.ts +1 -2
- package/dist/lib/runtime-reconcile.js +1 -156
- package/dist/lib/runtime-runs.d.ts +1 -11
- package/dist/lib/runtime-runs.js +1 -250
- package/dist/lib/runtime-types.d.ts +1 -43
- package/dist/lib/runtime-types.js +1 -1
- package/dist/lib/runtime.d.ts +1 -6
- package/dist/lib/runtime.js +1 -5
- package/dist/lib/schema.d.ts +4 -1016
- package/dist/lib/schema.js +6 -539
- package/dist/lib/source-config.d.ts +1 -39
- package/dist/lib/source-config.js +3 -293
- package/dist/lib/state-artifacts.d.ts +1 -8
- package/dist/lib/state-artifacts.js +1 -13
- package/dist/lib/state-health.d.ts +1 -4
- package/dist/lib/state-health.js +1 -132
- package/dist/lib/state-io.d.ts +1 -10
- package/dist/lib/state-io.js +1 -76
- package/dist/lib/state-paths.d.ts +1 -4
- package/dist/lib/state-paths.js +1 -13
- package/dist/lib/state-view.d.ts +1 -4
- package/dist/lib/state-view.js +1 -103
- package/dist/lib/state.d.ts +1 -6
- package/dist/lib/state.js +1 -5
- package/dist/lib/test-execution.d.ts +1 -14
- package/dist/lib/test-execution.js +3 -525
- package/dist/lib/test-matrices.d.ts +1 -90
- package/dist/lib/test-matrices.js +3 -96
- package/dist/lib/test-paths.d.ts +1 -12
- package/dist/lib/test-paths.js +3 -59
- package/dist/lib/test-profile-presets.d.ts +1 -57
- package/dist/lib/test-profile-presets.js +3 -50
- package/dist/lib/test-sandbox.d.ts +1 -11
- package/dist/lib/test-sandbox.js +3 -105
- package/dist/lib/test-specs.d.ts +1 -7
- package/dist/lib/test-specs.js +3 -114
- package/dist/lib/test-targets.d.ts +1 -5
- package/dist/lib/test-targets.js +3 -38
- package/dist/lib/test-types.d.ts +1 -17
- package/dist/lib/test-types.js +3 -1
- package/dist/lib/test.d.ts +1 -4
- package/dist/lib/test.js +3 -3
- package/dist/lib/validate-compiled.d.ts +1 -27
- package/dist/lib/validate-compiled.js +1 -238
- package/dist/lib/validate-helpers.d.ts +1 -12
- package/dist/lib/validate-helpers.js +1 -41
- package/dist/lib/validate.d.ts +1 -19
- package/dist/lib/validate.js +1 -256
- package/dist/lib/workflow-authoring.d.ts +1 -0
- package/dist/lib/workflow-authoring.js +1 -0
- package/dist/lib/workflow-definitions.d.ts +1 -68
- package/dist/lib/workflow-definitions.js +1 -206
- package/dist/lib/workflow-edit-session.d.ts +1 -0
- package/dist/lib/workflow-edit-session.js +1 -0
- package/dist/lib/workflow-edit-utils.d.ts +1 -0
- package/dist/lib/workflow-edit-utils.js +1 -0
- package/dist/lib/workflow-helpers.d.ts +1 -38
- package/dist/lib/workflow-helpers.js +1 -167
- package/dist/lib/workflow-improvement.d.ts +1 -22
- package/dist/lib/workflow-improvement.js +1 -396
- package/dist/lib/workflow-primitives.d.ts +1 -2
- package/dist/lib/workflow-primitives.js +1 -5
- package/dist/lib/workflow-review-paths.d.ts +1 -10
- package/dist/lib/workflow-review-paths.js +1 -27
- package/dist/lib/workflow-stage-policy.d.ts +1 -0
- package/dist/lib/workflow-stage-policy.js +1 -0
- package/dist/lib/workflow-stage-runner.d.ts +1 -41
- package/dist/lib/workflow-stage-runner.js +1 -109
- package/dist/lib/workflows.d.ts +1 -15
- package/dist/lib/workflows.js +1 -31
- package/dist/packages/agents/index.d.ts +17 -0
- package/dist/packages/agents/index.js +15 -0
- package/dist/packages/agents/lib/agents.d.ts +6 -0
- package/dist/packages/agents/lib/agents.js +5 -0
- package/dist/packages/agents/lib/args.d.ts +4 -0
- package/dist/packages/agents/lib/args.js +52 -0
- package/dist/packages/agents/lib/constants.d.ts +5 -0
- package/dist/packages/agents/lib/constants.js +28 -0
- package/dist/packages/agents/lib/detection.d.ts +7 -0
- package/dist/packages/agents/lib/detection.js +65 -0
- package/dist/packages/agents/lib/execution-profile.d.ts +17 -0
- package/dist/packages/agents/lib/execution-profile.js +84 -0
- package/dist/packages/agents/lib/execution.d.ts +2 -0
- package/dist/packages/agents/lib/execution.js +243 -0
- package/dist/packages/agents/lib/executors.d.ts +32 -0
- package/dist/packages/agents/lib/executors.js +45 -0
- package/dist/packages/agents/lib/logs.d.ts +2 -0
- package/dist/packages/agents/lib/logs.js +17 -0
- package/dist/packages/agents/lib/preflight.d.ts +7 -0
- package/dist/packages/agents/lib/preflight.js +77 -0
- package/dist/packages/agents/lib/render.d.ts +8 -0
- package/dist/packages/agents/lib/render.js +218 -0
- package/dist/packages/agents/lib/schema.d.ts +8 -0
- package/dist/packages/agents/lib/schema.js +7 -0
- package/dist/packages/agents/lib/shells.d.ts +69 -0
- package/dist/packages/agents/lib/shells.js +1021 -0
- package/dist/packages/agents/lib/status.d.ts +3 -0
- package/dist/packages/agents/lib/status.js +58 -0
- package/dist/packages/agents/lib/types.d.ts +30 -0
- package/dist/packages/agents/lib/types.js +1 -0
- package/dist/{lib → packages/agents/lib}/user-config.d.ts +1 -0
- package/dist/{lib → packages/agents/lib}/user-config.js +3 -2
- package/dist/packages/compiler/compiled-compile.d.ts +48 -0
- package/dist/packages/compiler/compiled-compile.js +256 -0
- package/dist/packages/compiler/compiled-schema.d.ts +31 -0
- package/dist/packages/compiler/compiled-schema.js +141 -0
- package/dist/packages/compiler/index.d.ts +24 -0
- package/dist/packages/compiler/index.js +23 -0
- package/dist/packages/compiler/lib/schema.d.ts +684 -0
- package/dist/packages/compiler/lib/schema.js +361 -0
- package/dist/packages/compiler/runtime-acceptance.d.ts +9 -0
- package/dist/packages/compiler/runtime-acceptance.js +269 -0
- package/dist/packages/compiler/runtime-contracts.d.ts +2 -0
- package/dist/packages/compiler/runtime-contracts.js +48 -0
- package/dist/packages/compiler/runtime-inventory.d.ts +7 -0
- package/dist/packages/compiler/runtime-inventory.js +29 -0
- package/dist/packages/compiler/runtime-paths.d.ts +8 -0
- package/dist/packages/compiler/runtime-paths.js +26 -0
- package/dist/packages/compiler/runtime-prompt.d.ts +2 -0
- package/dist/packages/compiler/runtime-prompt.js +48 -0
- package/dist/packages/compiler/runtime-reconcile.d.ts +2 -0
- package/dist/packages/compiler/runtime-reconcile.js +193 -0
- package/dist/packages/compiler/runtime-runs.d.ts +11 -0
- package/dist/packages/compiler/runtime-runs.js +262 -0
- package/dist/packages/compiler/runtime-types.d.ts +43 -0
- package/dist/packages/compiler/runtime-types.js +1 -0
- package/dist/packages/compiler/runtime.d.ts +6 -0
- package/dist/packages/compiler/runtime.js +5 -0
- package/dist/packages/compiler/state-artifacts.d.ts +8 -0
- package/dist/packages/compiler/state-artifacts.js +13 -0
- package/dist/packages/compiler/state-health.d.ts +4 -0
- package/dist/packages/compiler/state-health.js +132 -0
- package/dist/packages/compiler/state-io.d.ts +10 -0
- package/dist/packages/compiler/state-io.js +76 -0
- package/dist/packages/compiler/state-paths.d.ts +4 -0
- package/dist/packages/compiler/state-paths.js +13 -0
- package/dist/packages/compiler/state-view.d.ts +4 -0
- package/dist/packages/compiler/state-view.js +103 -0
- package/dist/packages/compiler/state.d.ts +7 -0
- package/dist/packages/compiler/state.js +12 -0
- package/dist/packages/compiler/validate-compiled.d.ts +27 -0
- package/dist/packages/compiler/validate-compiled.js +241 -0
- package/dist/packages/compiler/validate-helpers.d.ts +12 -0
- package/dist/packages/compiler/validate-helpers.js +41 -0
- package/dist/packages/compiler/validate.d.ts +21 -0
- package/dist/packages/compiler/validate.js +249 -0
- package/dist/packages/compiler/workflow-primitives.d.ts +2 -0
- package/dist/packages/compiler/workflow-primitives.js +5 -0
- package/dist/packages/compiler/workflows.d.ts +15 -0
- package/dist/packages/compiler/workflows.js +31 -0
- package/dist/packages/project-model/compiled-paths.d.ts +40 -0
- package/dist/packages/project-model/compiled-paths.js +106 -0
- package/dist/packages/project-model/compiled-raw.d.ts +49 -0
- package/dist/packages/project-model/compiled-raw.js +102 -0
- package/dist/packages/project-model/compiled-reset.d.ts +2 -0
- package/dist/packages/project-model/compiled-reset.js +72 -0
- package/dist/packages/project-model/index.d.ts +11 -0
- package/dist/packages/project-model/index.js +10 -0
- package/dist/packages/project-model/interf-bootstrap.d.ts +3 -0
- package/dist/packages/project-model/interf-bootstrap.js +18 -0
- package/dist/packages/project-model/interf-detect.d.ts +33 -0
- package/dist/packages/project-model/interf-detect.js +176 -0
- package/dist/packages/project-model/interf-scaffold.d.ts +2 -0
- package/dist/packages/project-model/interf-scaffold.js +124 -0
- package/dist/packages/project-model/interf.d.ts +5 -0
- package/dist/packages/project-model/interf.js +4 -0
- package/dist/packages/project-model/lib/schema.d.ts +125 -0
- package/dist/packages/project-model/lib/schema.js +62 -0
- package/dist/packages/project-model/project-paths.d.ts +11 -0
- package/dist/packages/project-model/project-paths.js +32 -0
- package/dist/packages/project-model/source-config.d.ts +38 -0
- package/dist/packages/project-model/source-config.js +297 -0
- package/dist/packages/testing/index.d.ts +13 -0
- package/dist/packages/testing/index.js +10 -0
- package/dist/packages/testing/lib/schema.d.ts +261 -0
- package/dist/packages/testing/lib/schema.js +119 -0
- package/dist/packages/testing/test-execution.d.ts +14 -0
- package/dist/packages/testing/test-execution.js +525 -0
- package/dist/packages/testing/test-matrices.d.ts +90 -0
- package/dist/packages/testing/test-matrices.js +96 -0
- package/dist/packages/testing/test-paths.d.ts +12 -0
- package/dist/packages/testing/test-paths.js +59 -0
- package/dist/packages/testing/test-profile-presets.d.ts +57 -0
- package/dist/packages/testing/test-profile-presets.js +50 -0
- package/dist/packages/testing/test-sandbox.d.ts +11 -0
- package/dist/packages/testing/test-sandbox.js +105 -0
- package/dist/packages/testing/test-specs.d.ts +7 -0
- package/dist/packages/testing/test-specs.js +114 -0
- package/dist/packages/testing/test-targets.d.ts +5 -0
- package/dist/packages/testing/test-targets.js +38 -0
- package/dist/packages/testing/test-types.d.ts +16 -0
- package/dist/packages/testing/test-types.js +1 -0
- package/dist/packages/testing/test.d.ts +4 -0
- package/dist/packages/testing/test.js +3 -0
- package/dist/packages/workflow-authoring/index.d.ts +4 -0
- package/dist/packages/workflow-authoring/index.js +4 -0
- package/dist/packages/workflow-authoring/lib/workflow-edit-utils.d.ts +10 -0
- package/dist/packages/workflow-authoring/lib/workflow-edit-utils.js +39 -0
- package/dist/packages/workflow-authoring/workflow-authoring.d.ts +26 -0
- package/dist/packages/workflow-authoring/workflow-authoring.js +120 -0
- package/dist/packages/workflow-authoring/workflow-edit-session.d.ts +16 -0
- package/dist/packages/workflow-authoring/workflow-edit-session.js +57 -0
- package/dist/packages/workflow-authoring/workflow-improvement.d.ts +23 -0
- package/dist/packages/workflow-authoring/workflow-improvement.js +209 -0
- package/dist/packages/workflow-package/builtin-compiled-workflow.d.ts +38 -0
- package/dist/packages/workflow-package/builtin-compiled-workflow.js +94 -0
- package/dist/packages/workflow-package/index.d.ts +9 -0
- package/dist/packages/workflow-package/index.js +9 -0
- package/dist/packages/workflow-package/interf-workflow-package.d.ts +25 -0
- package/dist/packages/workflow-package/interf-workflow-package.js +342 -0
- package/dist/{lib/config.d.ts → packages/workflow-package/lib/package-root.d.ts} +0 -1
- package/dist/packages/workflow-package/lib/package-root.js +6 -0
- package/dist/packages/workflow-package/local-workflows.d.ts +54 -0
- package/dist/packages/workflow-package/local-workflows.js +422 -0
- package/dist/packages/workflow-package/workflow-definitions.d.ts +78 -0
- package/dist/packages/workflow-package/workflow-definitions.js +203 -0
- package/dist/packages/workflow-package/workflow-helpers.d.ts +38 -0
- package/dist/packages/workflow-package/workflow-helpers.js +167 -0
- package/dist/packages/workflow-package/workflow-review-paths.d.ts +10 -0
- package/dist/packages/workflow-package/workflow-review-paths.js +27 -0
- package/dist/packages/workflow-package/workflow-stage-policy.d.ts +5 -0
- package/dist/packages/workflow-package/workflow-stage-policy.js +31 -0
- package/dist/packages/workflow-package/workflow-stage-runner.d.ts +41 -0
- package/dist/packages/workflow-package/workflow-stage-runner.js +109 -0
- package/package.json +44 -21
- package/dist/commands/compile.d.ts +0 -15
- package/dist/commands/create-workflow-wizard.js +0 -125
- package/dist/commands/create.js +0 -162
- package/dist/commands/init.d.ts +0 -3
- package/dist/commands/test.d.ts +0 -9
- package/dist/lib/compiled-home.d.ts +0 -5
- package/dist/lib/compiled-home.js +0 -32
- package/dist/lib/config.js +0 -9
- package/dist/lib/obsidian.d.ts +0 -1
- package/dist/lib/obsidian.js +0 -15
- package/dist/lib/summarize-plan.d.ts +0 -17
- package/dist/lib/summarize-plan.js +0 -120
- /package/dist/{commands → cli/commands}/default.d.ts +0 -0
- /package/dist/{commands → cli/commands}/doctor.d.ts +0 -0
- /package/dist/{commands → cli/commands}/list.d.ts +0 -0
- /package/dist/{commands → cli/commands}/reset.d.ts +0 -0
- /package/dist/{commands → cli/commands}/status.d.ts +0 -0
- /package/dist/{commands → cli/commands}/verify.d.ts +0 -0
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import * as p from "@clack/prompts";
|
|
3
|
-
import { detectInterf, readInterfConfig, resolveSourceControlPath, } from "
|
|
4
|
-
import { sourceDatasetConfigFromInterfConfig, } from "
|
|
5
|
-
import { addExecutionProfileOptions, executionProfileFromArgv, } from "
|
|
3
|
+
import { detectInterf, readInterfConfig, resolveSourceControlPath, } from "../../packages/project-model/interf.js";
|
|
4
|
+
import { loadCompiledDatasetConfig, sourceDatasetConfigFromInterfConfig, resolveDatasetCompileMaxAttempts, resolveDatasetCompileMaxLoops, } from "../../packages/project-model/source-config.js";
|
|
5
|
+
import { addExecutionProfileOptions, executionProfileFromArgv, } from "../../packages/agents/lib/execution-profile.js";
|
|
6
6
|
import { chooseCompiledConfigToBuild, ensureCompiledFromConfig, } from "./compiled-flow.js";
|
|
7
|
+
import { resolveConfiguredDatasetSelection } from "./dataset-selection.js";
|
|
7
8
|
import { promptCompileLoopSelection, } from "./source-config-wizard.js";
|
|
8
9
|
import { resolveOrConfigureLocalExecutor } from "./executor-flow.js";
|
|
9
10
|
import { runConfiguredCompiledCompile } from "./compile-controller.js";
|
|
10
11
|
export { runConfiguredCompiledCompile } from "./compile-controller.js";
|
|
11
12
|
export const compileCommand = {
|
|
12
13
|
command: "compile",
|
|
13
|
-
describe: "Build
|
|
14
|
+
describe: "Build a compiled context and optionally run retry or self-improving compile loops",
|
|
14
15
|
builder: (yargs) => addExecutionProfileOptions(yargs).option("max-attempts", {
|
|
15
16
|
type: "number",
|
|
16
|
-
describe: "Retry compile +
|
|
17
|
+
describe: "Retry compile + check for the same workflow until the dataset passes or reaches this total attempt limit",
|
|
17
18
|
}).option("max-loops", {
|
|
18
19
|
type: "number",
|
|
19
20
|
describe: "After retries fail, let Interf edit the workflow and test new workflow variations for this dataset up to this loop limit",
|
|
@@ -26,48 +27,106 @@ export const compileCommand = {
|
|
|
26
27
|
await runCompileCommand(argv);
|
|
27
28
|
},
|
|
28
29
|
};
|
|
29
|
-
|
|
30
|
+
const defaultCompileCommandDeps = {
|
|
31
|
+
chooseCompiledConfigToBuild,
|
|
32
|
+
confirm: p.confirm,
|
|
33
|
+
detectInterf,
|
|
34
|
+
ensureCompiledFromConfig,
|
|
35
|
+
resolveInteractiveCompileLoopOverrides,
|
|
36
|
+
resolveOrConfigureLocalExecutor,
|
|
37
|
+
runConfiguredCompiledCompile,
|
|
38
|
+
};
|
|
39
|
+
function readHintedSourcePath(argv) {
|
|
40
|
+
return typeof argv.sourcePath === "string" && argv.sourcePath.trim().length > 0
|
|
41
|
+
? argv.sourcePath.trim()
|
|
42
|
+
: null;
|
|
43
|
+
}
|
|
44
|
+
function readRequestedDatasetName(argv) {
|
|
45
|
+
return typeof argv.dataset === "string" && argv.dataset.trim().length > 0
|
|
46
|
+
? argv.dataset.trim()
|
|
47
|
+
: null;
|
|
48
|
+
}
|
|
49
|
+
function shouldSkipCompileConfirm(argv) {
|
|
50
|
+
return argv.skipConfirm === true;
|
|
51
|
+
}
|
|
52
|
+
function shouldSkipDatasetBanner(argv) {
|
|
53
|
+
return argv.skipDatasetBanner === true;
|
|
54
|
+
}
|
|
55
|
+
function compileRunTests(options) {
|
|
56
|
+
const checks = options.compiledConfig?.checks ?? [];
|
|
57
|
+
if (checks.length === 0)
|
|
58
|
+
return false;
|
|
59
|
+
const configuredMaxAttempts = resolveDatasetCompileMaxAttempts(options.compiledConfig ?? { max_attempts: undefined }, options.maxAttemptsOverride);
|
|
60
|
+
const maxLoops = resolveDatasetCompileMaxLoops(options.compiledConfig ?? { max_loops: undefined }, options.maxLoopsOverride);
|
|
61
|
+
const maxAttempts = configuredMaxAttempts ?? (maxLoops != null ? 1 : null);
|
|
62
|
+
return maxAttempts != null;
|
|
63
|
+
}
|
|
64
|
+
export async function runCompileCommand(argv = {}, deps = {}) {
|
|
65
|
+
const helpers = {
|
|
66
|
+
...defaultCompileCommandDeps,
|
|
67
|
+
...deps,
|
|
68
|
+
};
|
|
30
69
|
let compiledPath = null;
|
|
31
|
-
|
|
70
|
+
const hintedSourcePath = readHintedSourcePath(argv);
|
|
71
|
+
const detected = hintedSourcePath ? null : helpers.detectInterf(process.cwd());
|
|
72
|
+
let sourcePath = hintedSourcePath ?? process.cwd();
|
|
32
73
|
let compiledConfig = null;
|
|
33
|
-
const
|
|
74
|
+
const requestedDatasetName = readRequestedDatasetName(argv);
|
|
75
|
+
const hintedDatasetConfig = (argv.datasetConfig ?? null);
|
|
76
|
+
const skipConfirm = shouldSkipCompileConfirm(argv);
|
|
77
|
+
const skipDatasetBanner = shouldSkipDatasetBanner(argv);
|
|
34
78
|
if (detected) {
|
|
35
79
|
compiledPath = detected.path;
|
|
36
80
|
sourcePath = resolveSourceControlPath(detected.path);
|
|
37
|
-
compiledConfig =
|
|
38
|
-
|
|
39
|
-
|
|
81
|
+
compiledConfig = loadCompiledDatasetConfig(detected.path)
|
|
82
|
+
?? sourceDatasetConfigFromInterfConfig(detected.config);
|
|
83
|
+
if (!skipConfirm && process.stdin.isTTY && process.stdout.isTTY) {
|
|
84
|
+
const confirmed = await helpers.confirm({
|
|
40
85
|
message: `Compile dataset "${detected.config.name}" now?`,
|
|
41
86
|
initialValue: true,
|
|
42
87
|
});
|
|
43
88
|
if (p.isCancel(confirmed) || !confirmed)
|
|
44
|
-
return;
|
|
89
|
+
return null;
|
|
45
90
|
}
|
|
46
91
|
}
|
|
47
92
|
else {
|
|
48
|
-
const selectedCompiled =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
93
|
+
const selectedCompiled = requestedDatasetName || hintedDatasetConfig
|
|
94
|
+
? resolveConfiguredDatasetSelection({
|
|
95
|
+
sourcePath,
|
|
96
|
+
requestedDatasetName,
|
|
97
|
+
hintedDatasetConfig,
|
|
98
|
+
})
|
|
99
|
+
: await helpers.chooseCompiledConfigToBuild({
|
|
100
|
+
sourcePath,
|
|
101
|
+
selectMessage: "Which source folder setup do you want to compile?",
|
|
102
|
+
});
|
|
52
103
|
if (selectedCompiled === undefined)
|
|
53
|
-
return;
|
|
104
|
+
return null;
|
|
54
105
|
if (!selectedCompiled) {
|
|
55
106
|
process.exitCode = 1;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
107
|
+
if (requestedDatasetName) {
|
|
108
|
+
console.log(chalk.red(` Setup "${requestedDatasetName}" is not set up in this project.`));
|
|
109
|
+
console.log(chalk.dim(" Run `interf list` to see the saved setups."));
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
console.log(chalk.red(" No saved setups are configured for this folder yet."));
|
|
113
|
+
console.log(chalk.dim(" Start with `interf` or `interf init` to set up this folder."));
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
59
116
|
}
|
|
60
|
-
if (process.stdin.isTTY && process.stdout.isTTY) {
|
|
61
|
-
const confirmed = await
|
|
117
|
+
if (!skipConfirm && process.stdin.isTTY && process.stdout.isTTY) {
|
|
118
|
+
const confirmed = await helpers.confirm({
|
|
62
119
|
message: `Compile dataset "${selectedCompiled.name}" now?`,
|
|
63
120
|
initialValue: true,
|
|
64
121
|
});
|
|
65
122
|
if (p.isCancel(confirmed) || !confirmed)
|
|
66
|
-
return;
|
|
123
|
+
return null;
|
|
67
124
|
}
|
|
68
125
|
compiledConfig = selectedCompiled;
|
|
69
|
-
compiledPath = ensureCompiledFromConfig(
|
|
70
|
-
|
|
126
|
+
compiledPath = helpers.ensureCompiledFromConfig(sourcePath, selectedCompiled);
|
|
127
|
+
if (!skipDatasetBanner) {
|
|
128
|
+
console.log(chalk.dim(` Dataset: ${selectedCompiled.name}`));
|
|
129
|
+
}
|
|
71
130
|
}
|
|
72
131
|
let maxAttemptsOverride = null;
|
|
73
132
|
let maxLoopsOverride = null;
|
|
@@ -78,32 +137,37 @@ export async function runCompileCommand(argv = {}) {
|
|
|
78
137
|
catch (error) {
|
|
79
138
|
process.exitCode = 1;
|
|
80
139
|
console.log(chalk.red(error instanceof Error ? error.message : String(error)));
|
|
81
|
-
return;
|
|
140
|
+
return null;
|
|
82
141
|
}
|
|
83
|
-
const interactiveOverrides = await resolveInteractiveCompileLoopOverrides({
|
|
142
|
+
const interactiveOverrides = await helpers.resolveInteractiveCompileLoopOverrides({
|
|
84
143
|
compiledPath,
|
|
85
144
|
compiledConfig,
|
|
86
145
|
maxAttemptsOverride,
|
|
87
146
|
maxLoopsOverride,
|
|
88
147
|
});
|
|
89
148
|
if (!interactiveOverrides)
|
|
90
|
-
return;
|
|
149
|
+
return null;
|
|
91
150
|
compiledConfig = interactiveOverrides.compiledConfig;
|
|
92
151
|
maxAttemptsOverride = interactiveOverrides.maxAttemptsOverride;
|
|
93
152
|
maxLoopsOverride = interactiveOverrides.maxLoopsOverride;
|
|
153
|
+
const testedDuringCompile = compileRunTests({
|
|
154
|
+
compiledConfig,
|
|
155
|
+
maxAttemptsOverride,
|
|
156
|
+
maxLoopsOverride,
|
|
157
|
+
});
|
|
94
158
|
const executionProfile = executionProfileFromArgv(argv);
|
|
95
|
-
const { executor, error } = await resolveOrConfigureLocalExecutor({
|
|
159
|
+
const { executor, error } = await helpers.resolveOrConfigureLocalExecutor({
|
|
96
160
|
executionProfile,
|
|
97
161
|
purpose: "compile",
|
|
98
162
|
});
|
|
99
163
|
if (!executor && !error)
|
|
100
|
-
return;
|
|
164
|
+
return null;
|
|
101
165
|
if (!executor) {
|
|
102
166
|
process.exitCode = 1;
|
|
103
167
|
console.log(chalk.red(error ?? "No coding agent detected."));
|
|
104
|
-
return;
|
|
168
|
+
return null;
|
|
105
169
|
}
|
|
106
|
-
await runConfiguredCompiledCompile({
|
|
170
|
+
const compiled = await helpers.runConfiguredCompiledCompile({
|
|
107
171
|
executor,
|
|
108
172
|
compiledPath,
|
|
109
173
|
sourcePath,
|
|
@@ -113,6 +177,13 @@ export async function runCompileCommand(argv = {}) {
|
|
|
113
177
|
maxLoopsOverride,
|
|
114
178
|
preserveStageShells: readStageShellRetentionMode(argv),
|
|
115
179
|
});
|
|
180
|
+
if (!compiled) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
compiledPath,
|
|
185
|
+
testedDuringCompile,
|
|
186
|
+
};
|
|
116
187
|
}
|
|
117
188
|
export async function resolveInteractiveCompileLoopOverrides(options) {
|
|
118
189
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
@@ -141,7 +212,10 @@ export async function resolveInteractiveCompileLoopOverrides(options) {
|
|
|
141
212
|
};
|
|
142
213
|
}
|
|
143
214
|
const savedCompiledConfig = options.compiledConfig
|
|
144
|
-
?? (currentConfig
|
|
215
|
+
?? (currentConfig
|
|
216
|
+
? (loadCompiledDatasetConfig(options.compiledPath)
|
|
217
|
+
?? sourceDatasetConfigFromInterfConfig(currentConfig))
|
|
218
|
+
: null);
|
|
145
219
|
if (!savedCompiledConfig) {
|
|
146
220
|
return {
|
|
147
221
|
compiledConfig: options.compiledConfig,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { SourceDatasetConfig } from "
|
|
2
|
-
import { type StageShellRetentionMode } from "
|
|
3
|
-
import type { WorkflowExecutor } from "
|
|
4
|
-
import type { CompiledCompileResult } from "../lib/workflows.js";
|
|
1
|
+
import type { SourceDatasetConfig } from "../../packages/project-model/lib/schema.js";
|
|
2
|
+
import { type StageShellRetentionMode, type CompiledCompileResult } from "../../packages/compiler/workflows.js";
|
|
3
|
+
import type { WorkflowExecutor } from "../../packages/agents/lib/executors.js";
|
|
5
4
|
export interface SavedDatasetEntry {
|
|
6
5
|
config: SourceDatasetConfig;
|
|
7
6
|
path: string | null;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import * as p from "@clack/prompts";
|
|
3
|
-
import { listCompiledDatasetsForSourceFolder } from "
|
|
4
|
-
import { listSourceDatasetConfigs, loadCompiledDatasetConfig, loadSourceFolderConfig, resolveSourceDatasetPath, sourceDatasetConfigFromInterfConfig, syncCompiledInterfConfigFromSourceDatasetConfig, } from "
|
|
5
|
-
import { compileCompiled, createCompiled, } from "
|
|
6
|
-
import { formatWorkflowExecutionProfile } from "
|
|
3
|
+
import { listCompiledDatasetsForSourceFolder } from "../../packages/project-model/interf.js";
|
|
4
|
+
import { listSourceDatasetConfigs, loadCompiledDatasetConfig, loadSourceFolderConfig, resolveSourceDatasetPath, sourceDatasetConfigFromInterfConfig, syncCompiledInterfConfigFromSourceDatasetConfig, } from "../../packages/project-model/source-config.js";
|
|
5
|
+
import { compileCompiled, createCompiled, } from "../../packages/compiler/workflows.js";
|
|
6
|
+
import { formatWorkflowExecutionProfile } from "../../packages/agents/lib/execution-profile.js";
|
|
7
7
|
function formatSavedDatasetHint(entry) {
|
|
8
8
|
const config = entry.config;
|
|
9
9
|
const checkCount = config.checks.length;
|
|
10
10
|
const workflowHint = `workflow ${config.workflow ?? "interf"}${entry.localDraft ? " (local draft)" : ""}`;
|
|
11
11
|
if (config.about)
|
|
12
|
-
return `${config.about} · ${workflowHint}`;
|
|
12
|
+
return `${config.path} · ${config.about} · ${workflowHint}`;
|
|
13
13
|
if (checkCount === 0)
|
|
14
|
-
return
|
|
15
|
-
return `${
|
|
14
|
+
return `${config.path} · No checks yet · ${workflowHint}`;
|
|
15
|
+
return `${config.path} · ${checkCount} check${checkCount === 1 ? "" : "s"} · ${workflowHint}`;
|
|
16
16
|
}
|
|
17
17
|
export function listSavedCompiledEntries(sourcePath) {
|
|
18
18
|
const builtEntries = new Map();
|
|
@@ -34,11 +34,6 @@ export function listSavedCompiledEntries(sourcePath) {
|
|
|
34
34
|
localDraft: built?.localDraft ?? false,
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
for (const [name, built] of builtEntries.entries()) {
|
|
38
|
-
if (entries.has(name))
|
|
39
|
-
continue;
|
|
40
|
-
entries.set(name, built);
|
|
41
|
-
}
|
|
42
37
|
return Array.from(entries.values()).sort((left, right) => left.config.name.localeCompare(right.config.name));
|
|
43
38
|
}
|
|
44
39
|
export function findBuiltCompiledPath(sourcePath, compiledName) {
|
|
@@ -87,7 +82,7 @@ export function ensureCompiledFromConfig(sourcePath, datasetConfig) {
|
|
|
87
82
|
}
|
|
88
83
|
export async function compileCompiledWithReporter(executor, compiledPath, options = {}) {
|
|
89
84
|
console.log();
|
|
90
|
-
console.log(chalk.bold(` ${options.heading ?? "Building compiled
|
|
85
|
+
console.log(chalk.bold(` ${options.heading ?? "Building compiled context..."}`));
|
|
91
86
|
const profileLabel = formatWorkflowExecutionProfile(executor.executionProfile);
|
|
92
87
|
if (profileLabel) {
|
|
93
88
|
console.log(chalk.dim(` Execution profile: ${profileLabel}`));
|
|
@@ -107,6 +102,6 @@ export async function compileCompiledWithReporter(executor, compiledPath, option
|
|
|
107
102
|
return result;
|
|
108
103
|
}
|
|
109
104
|
console.log();
|
|
110
|
-
console.log(chalk.green(` ✓ ${options.successMessage ?? "Compiled
|
|
105
|
+
console.log(chalk.green(` ✓ ${options.successMessage ?? "Compiled context ready."}`));
|
|
111
106
|
return result;
|
|
112
107
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { resolveOrConfigureLocalExecutor } from "./executor-flow.js";
|
|
2
|
+
import { runWorkflowAuthoringDraft } from "../../packages/workflow-authoring/workflow-authoring.js";
|
|
3
|
+
import type { SourceDatasetConfig } from "../../packages/project-model/lib/schema.js";
|
|
4
|
+
import type { WorkflowExecutionProfile } from "../../packages/agents/lib/executors.js";
|
|
1
5
|
export interface WorkflowWizardPrompts {
|
|
2
6
|
intro(message: string): void;
|
|
3
7
|
select(options: {
|
|
@@ -17,8 +21,13 @@ export interface WorkflowWizardPrompts {
|
|
|
17
21
|
isCancel(value: unknown): value is symbol;
|
|
18
22
|
log: {
|
|
19
23
|
info(message: string): void;
|
|
24
|
+
error?(message: string): void;
|
|
20
25
|
};
|
|
21
26
|
}
|
|
27
|
+
export interface WorkflowWizardDatasetContext {
|
|
28
|
+
config: SourceDatasetConfig;
|
|
29
|
+
datasetPath: string;
|
|
30
|
+
}
|
|
22
31
|
export declare const clackWorkflowPrompts: WorkflowWizardPrompts;
|
|
23
32
|
export declare function formatWorkflowLabel(workflow: {
|
|
24
33
|
id: string;
|
|
@@ -42,5 +51,14 @@ export declare function chooseCompiledWorkflow(sourcePath: string, options?: {
|
|
|
42
51
|
export declare function createWorkflowWizard(options?: {
|
|
43
52
|
intro?: boolean;
|
|
44
53
|
sourcePath?: string;
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
executionProfile?: WorkflowExecutionProfile;
|
|
55
|
+
datasetContext?: WorkflowWizardDatasetContext;
|
|
56
|
+
resolveExecutor?: typeof resolveOrConfigureLocalExecutor;
|
|
57
|
+
runDraft?: typeof runWorkflowAuthoringDraft;
|
|
58
|
+
}, prompts?: WorkflowWizardPrompts): Promise<string | symbol | null>;
|
|
59
|
+
export declare function createCompiledWorkflowWizard(sourcePath: string, prompts?: WorkflowWizardPrompts, options?: {
|
|
60
|
+
executionProfile?: WorkflowExecutionProfile;
|
|
61
|
+
datasetContext?: WorkflowWizardDatasetContext;
|
|
62
|
+
resolveExecutor?: typeof resolveOrConfigureLocalExecutor;
|
|
63
|
+
runDraft?: typeof runWorkflowAuthoringDraft;
|
|
64
|
+
}): Promise<string | symbol | null>;
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import * as p from "@clack/prompts";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { listCompiledWorkflowChoices, getCompiledWorkflow, } from "../../packages/workflow-package/workflow-definitions.js";
|
|
5
|
+
import { createLocalWorkflowPackageFromTemplate } from "../../packages/workflow-package/interf-workflow-package.js";
|
|
6
|
+
import { isWorkflowId, } from "../../packages/workflow-package/local-workflows.js";
|
|
7
|
+
import { resolveOrConfigureLocalExecutor } from "./executor-flow.js";
|
|
8
|
+
import { runWorkflowAuthoringDraft } from "../../packages/workflow-authoring/workflow-authoring.js";
|
|
9
|
+
import { listSourceDatasetConfigs, loadSourceFolderConfig, resolveSourceDatasetPath, } from "../../packages/project-model/source-config.js";
|
|
10
|
+
import { slugify } from "../../lib/util.js";
|
|
11
|
+
import { DEFAULT_DATASET_PATH_PLACEHOLDER, listDatasetFolderChoices, normalizeDatasetPathForConfig, } from "./source-config-wizard.js";
|
|
12
|
+
export const clackWorkflowPrompts = {
|
|
13
|
+
intro: p.intro,
|
|
14
|
+
select: (options) => p.select(options),
|
|
15
|
+
text: (options) => p.text(options),
|
|
16
|
+
isCancel: p.isCancel,
|
|
17
|
+
log: {
|
|
18
|
+
info: p.log.info,
|
|
19
|
+
error: p.log.error,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
function findMatchingDatasetConfig(sourcePath, datasetPath) {
|
|
23
|
+
const config = loadSourceFolderConfig(sourcePath);
|
|
24
|
+
for (const dataset of listSourceDatasetConfigs(config)) {
|
|
25
|
+
if (resolveSourceDatasetPath(sourcePath, dataset) === datasetPath) {
|
|
26
|
+
return dataset;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
function describeSavedDataset(dataset) {
|
|
32
|
+
return dataset.about
|
|
33
|
+
? `${dataset.path} · ${dataset.about}`
|
|
34
|
+
: `${dataset.path} · ${dataset.checks.length} check${dataset.checks.length === 1 ? "" : "s"}`;
|
|
35
|
+
}
|
|
36
|
+
async function promptWorkflowDatasetFolder(sourcePath, prompts) {
|
|
37
|
+
const folderChoices = listDatasetFolderChoices(sourcePath);
|
|
38
|
+
if (folderChoices.length > 0) {
|
|
39
|
+
const selected = await prompts.select({
|
|
40
|
+
message: "Which source folder should shape this workflow?",
|
|
41
|
+
options: [
|
|
42
|
+
...folderChoices,
|
|
43
|
+
{
|
|
44
|
+
value: "__manual__",
|
|
45
|
+
label: "Enter a different path",
|
|
46
|
+
hint: "Use a relative path if the source folder is not listed here",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
if (prompts.isCancel(selected))
|
|
51
|
+
return selected;
|
|
52
|
+
if (selected !== "__manual__") {
|
|
53
|
+
return resolve(sourcePath, normalizeDatasetPathForConfig(sourcePath, String(selected)));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const datasetFolder = await prompts.text({
|
|
57
|
+
message: "Which source folder should shape this workflow?",
|
|
58
|
+
placeholder: DEFAULT_DATASET_PATH_PLACEHOLDER,
|
|
59
|
+
initialValue: folderChoices.length === 1 ? folderChoices[0]?.value : undefined,
|
|
60
|
+
validate: (value) => {
|
|
61
|
+
const trimmed = value.trim();
|
|
62
|
+
if (trimmed.length === 0)
|
|
63
|
+
return "Source folder is required";
|
|
64
|
+
try {
|
|
65
|
+
normalizeDatasetPathForConfig(sourcePath, trimmed);
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
return error instanceof Error ? error.message : String(error);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
if (prompts.isCancel(datasetFolder))
|
|
74
|
+
return datasetFolder;
|
|
75
|
+
return resolve(sourcePath, normalizeDatasetPathForConfig(sourcePath, String(datasetFolder)));
|
|
76
|
+
}
|
|
77
|
+
export function formatWorkflowLabel(workflow) {
|
|
78
|
+
return {
|
|
79
|
+
value: workflow.id,
|
|
80
|
+
label: workflow.scope === "local" ? `${workflow.label} (Local)` : workflow.label,
|
|
81
|
+
hint: workflow.hint,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export function buildCompiledWorkflowOptions(sourcePath) {
|
|
85
|
+
return listCompiledWorkflowChoices(sourcePath).map(formatWorkflowLabel);
|
|
86
|
+
}
|
|
87
|
+
export async function chooseCompiledWorkflow(sourcePath, options = {}) {
|
|
88
|
+
const currentWorkflowId = options.currentWorkflowId;
|
|
89
|
+
const workflowOptions = buildCompiledWorkflowOptions(sourcePath);
|
|
90
|
+
const orderedOptions = workflowOptions
|
|
91
|
+
.map((option) => option.value === currentWorkflowId
|
|
92
|
+
? {
|
|
93
|
+
...option,
|
|
94
|
+
label: `${option.label} (Current)`,
|
|
95
|
+
hint: option.hint,
|
|
96
|
+
}
|
|
97
|
+
: option)
|
|
98
|
+
.sort((left, right) => {
|
|
99
|
+
if (left.value === currentWorkflowId)
|
|
100
|
+
return -1;
|
|
101
|
+
if (right.value === currentWorkflowId)
|
|
102
|
+
return 1;
|
|
103
|
+
return 0;
|
|
104
|
+
});
|
|
105
|
+
if (orderedOptions.length === 1) {
|
|
106
|
+
return orderedOptions[0]?.value ?? "interf";
|
|
107
|
+
}
|
|
108
|
+
return p.select({
|
|
109
|
+
message: options.message ?? "Dataset workflow?",
|
|
110
|
+
options: orderedOptions,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
export async function createWorkflowWizard(options = {}, prompts = clackWorkflowPrompts) {
|
|
114
|
+
if (options.intro !== false) {
|
|
115
|
+
prompts.intro(chalk.bold("Create a workflow"));
|
|
116
|
+
}
|
|
117
|
+
const sourcePath = options.sourcePath ?? process.cwd();
|
|
118
|
+
return createCompiledWorkflowWizard(sourcePath, prompts, {
|
|
119
|
+
executionProfile: options.executionProfile,
|
|
120
|
+
datasetContext: options.datasetContext,
|
|
121
|
+
resolveExecutor: options.resolveExecutor,
|
|
122
|
+
runDraft: options.runDraft,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
export async function createCompiledWorkflowWizard(sourcePath, prompts = clackWorkflowPrompts, options = {}) {
|
|
126
|
+
const baseWorkflow = await prompts.select({
|
|
127
|
+
message: "Start from which existing workflow?",
|
|
128
|
+
options: listCompiledWorkflowChoices(sourcePath).map(formatWorkflowLabel),
|
|
129
|
+
});
|
|
130
|
+
if (prompts.isCancel(baseWorkflow))
|
|
131
|
+
return baseWorkflow;
|
|
132
|
+
const resolvedBaseWorkflow = getCompiledWorkflow(String(baseWorkflow), { sourcePath });
|
|
133
|
+
const creationMode = await prompts.select({
|
|
134
|
+
message: "How do you want to create it?",
|
|
135
|
+
options: [
|
|
136
|
+
{
|
|
137
|
+
value: "draft",
|
|
138
|
+
label: "Draft a workflow from this source folder (Recommended)",
|
|
139
|
+
hint: "Seed a workflow, build a preview, then let a local agent draft a reusable method for this task",
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
value: "manual",
|
|
143
|
+
label: "Copy an existing workflow",
|
|
144
|
+
hint: "Start from an existing workflow and edit stage guidance directly",
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
});
|
|
148
|
+
if (prompts.isCancel(creationMode))
|
|
149
|
+
return creationMode;
|
|
150
|
+
const rawName = await prompts.text({
|
|
151
|
+
message: "New workflow name?",
|
|
152
|
+
placeholder: "founder-research",
|
|
153
|
+
validate: (value) => {
|
|
154
|
+
if (value.trim().length === 0)
|
|
155
|
+
return "Name is required";
|
|
156
|
+
const workflowId = slugify(value);
|
|
157
|
+
if (!isWorkflowId(workflowId))
|
|
158
|
+
return "Use letters, numbers, and dashes only";
|
|
159
|
+
if (listCompiledWorkflowChoices(sourcePath).some((workflow) => workflow.id === workflowId)) {
|
|
160
|
+
return "That workflow name already exists";
|
|
161
|
+
}
|
|
162
|
+
return undefined;
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
if (prompts.isCancel(rawName))
|
|
166
|
+
return rawName;
|
|
167
|
+
const workflowId = slugify(rawName);
|
|
168
|
+
const label = rawName.trim();
|
|
169
|
+
const hint = await prompts.text({
|
|
170
|
+
message: "One-line workflow description?",
|
|
171
|
+
placeholder: "Bias toward evidence-backed summaries and strong retrieval structure",
|
|
172
|
+
validate: (value) => (value.trim().length === 0 ? "Description is required" : undefined),
|
|
173
|
+
});
|
|
174
|
+
if (prompts.isCancel(hint))
|
|
175
|
+
return hint;
|
|
176
|
+
if (creationMode === "draft") {
|
|
177
|
+
let datasetPath = options.datasetContext?.datasetPath ?? null;
|
|
178
|
+
let matchedDataset = options.datasetContext?.config ?? null;
|
|
179
|
+
if (!datasetPath) {
|
|
180
|
+
const savedDatasets = listSourceDatasetConfigs(loadSourceFolderConfig(sourcePath));
|
|
181
|
+
if (savedDatasets.length > 0) {
|
|
182
|
+
const datasetChoice = await prompts.select({
|
|
183
|
+
message: "Which source folder setup should shape this workflow?",
|
|
184
|
+
options: [
|
|
185
|
+
...savedDatasets.map((dataset) => ({
|
|
186
|
+
value: dataset.name,
|
|
187
|
+
label: dataset.name,
|
|
188
|
+
hint: describeSavedDataset(dataset),
|
|
189
|
+
})),
|
|
190
|
+
{
|
|
191
|
+
value: "__manual__",
|
|
192
|
+
label: "Enter folder path manually",
|
|
193
|
+
hint: "Use a folder that is not saved as a dataset yet",
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
});
|
|
197
|
+
if (prompts.isCancel(datasetChoice))
|
|
198
|
+
return datasetChoice;
|
|
199
|
+
if (datasetChoice !== "__manual__") {
|
|
200
|
+
matchedDataset = savedDatasets.find((dataset) => dataset.name === datasetChoice) ?? null;
|
|
201
|
+
datasetPath = matchedDataset
|
|
202
|
+
? resolveSourceDatasetPath(sourcePath, matchedDataset)
|
|
203
|
+
: null;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (!datasetPath) {
|
|
208
|
+
const datasetFolder = await promptWorkflowDatasetFolder(sourcePath, prompts);
|
|
209
|
+
if (prompts.isCancel(datasetFolder))
|
|
210
|
+
return datasetFolder;
|
|
211
|
+
if (!datasetFolder)
|
|
212
|
+
return null;
|
|
213
|
+
datasetPath = String(datasetFolder);
|
|
214
|
+
matchedDataset = matchedDataset ?? findMatchingDatasetConfig(sourcePath, datasetPath);
|
|
215
|
+
}
|
|
216
|
+
const taskPrompt = await prompts.text({
|
|
217
|
+
message: "What task should this workflow help with?",
|
|
218
|
+
placeholder: "Example: chart reads, board-prep questions, or latest planned launch status",
|
|
219
|
+
validate: (value) => (value.trim().length === 0 ? "Task focus is required" : undefined),
|
|
220
|
+
});
|
|
221
|
+
if (prompts.isCancel(taskPrompt))
|
|
222
|
+
return taskPrompt;
|
|
223
|
+
if (matchedDataset) {
|
|
224
|
+
prompts.log.info(`Shaping this workflow from setup "${matchedDataset.name}".`);
|
|
225
|
+
}
|
|
226
|
+
if (matchedDataset?.checks.length) {
|
|
227
|
+
prompts.log.info(`Using ${matchedDataset.checks.length} check${matchedDataset.checks.length === 1 ? "" : "s"} from setup "${matchedDataset.name}" as authoring context.`);
|
|
228
|
+
}
|
|
229
|
+
const resolveExecutor = options.resolveExecutor ?? resolveOrConfigureLocalExecutor;
|
|
230
|
+
const runDraft = options.runDraft ?? runWorkflowAuthoringDraft;
|
|
231
|
+
const { executor, error } = await resolveExecutor({
|
|
232
|
+
executionProfile: options.executionProfile,
|
|
233
|
+
purpose: "workflow",
|
|
234
|
+
});
|
|
235
|
+
if (!executor && !error) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
if (!executor) {
|
|
239
|
+
process.exitCode = 1;
|
|
240
|
+
(prompts.log.error ?? prompts.log.info)(error ?? "No coding agent detected.");
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
prompts.log.info("Preparing a workflow-authoring preview from the source folder, then drafting the package.");
|
|
244
|
+
const result = await runDraft({
|
|
245
|
+
sourcePath,
|
|
246
|
+
datasetPath,
|
|
247
|
+
baseWorkflowId: baseWorkflow,
|
|
248
|
+
workflowId,
|
|
249
|
+
label,
|
|
250
|
+
hint: hint.trim(),
|
|
251
|
+
taskPrompt: taskPrompt.trim(),
|
|
252
|
+
checks: matchedDataset?.checks ?? [],
|
|
253
|
+
executor,
|
|
254
|
+
preparePreview: true,
|
|
255
|
+
});
|
|
256
|
+
if (result.status === "updated") {
|
|
257
|
+
prompts.log.info(`Saved local workflow: ${result.workflowPath}`);
|
|
258
|
+
return workflowId;
|
|
259
|
+
}
|
|
260
|
+
process.exitCode = 1;
|
|
261
|
+
(prompts.log.error ?? prompts.log.info)(result.status === "no-change"
|
|
262
|
+
? `${result.summary} Draft mode only succeeds when it produces a task-specific package change.`
|
|
263
|
+
: result.summary);
|
|
264
|
+
prompts.log.info(`Workflow shell kept at: ${result.shellPath}`);
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
const stagePolicyNotes = {};
|
|
268
|
+
for (const stage of resolvedBaseWorkflow.stages) {
|
|
269
|
+
const stagePrompt = await prompts.text({
|
|
270
|
+
message: `What should ${stage.id} (${stage.label}) emphasize?`,
|
|
271
|
+
placeholder: stage.description,
|
|
272
|
+
validate: (value) => (value.trim().length === 0 ? `${stage.label} guidance is required` : undefined),
|
|
273
|
+
});
|
|
274
|
+
if (prompts.isCancel(stagePrompt))
|
|
275
|
+
return stagePrompt;
|
|
276
|
+
stagePolicyNotes[stage.id] = [String(stagePrompt).trim()];
|
|
277
|
+
}
|
|
278
|
+
const workflowPath = createLocalWorkflowPackageFromTemplate({
|
|
279
|
+
sourcePath,
|
|
280
|
+
baseWorkflowId: baseWorkflow,
|
|
281
|
+
workflowId,
|
|
282
|
+
label,
|
|
283
|
+
hint: hint.trim(),
|
|
284
|
+
stagePolicyNotes,
|
|
285
|
+
});
|
|
286
|
+
prompts.log.info(`Saved local workflow: ${workflowPath}`);
|
|
287
|
+
return workflowId;
|
|
288
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { CommandModule } from "yargs";
|
|
2
|
-
import type { WorkflowExecutionProfile } from "
|
|
2
|
+
import type { WorkflowExecutionProfile } from "../../packages/agents/lib/executors.js";
|
|
3
3
|
export declare const createCommand: CommandModule;
|
|
4
4
|
export declare function createCompiledWizard(options?: {
|
|
5
5
|
intro?: boolean;
|
|
6
6
|
executionProfile?: WorkflowExecutionProfile;
|
|
7
7
|
}): Promise<void>;
|
|
8
|
-
export { type WorkflowWizardPrompts, formatWorkflowLabel,
|
|
8
|
+
export { type WorkflowWizardPrompts, formatWorkflowLabel, createWorkflowWizard, createCompiledWorkflowWizard, } from "./create-workflow-wizard.js";
|