@interf/compiler 0.7.3 → 0.9.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/README.md +123 -89
- package/TRADEMARKS.md +1 -1
- package/agent-skills/interf-actions/SKILL.md +71 -0
- package/agent-skills/interf-actions/references/cli.md +190 -0
- package/apps/compiler-ui/.next/server/app/index.html +1 -0
- package/apps/compiler-ui/.next/static/XWKL548yXD_UOG4ID9G3J/_buildManifest.js +11 -0
- package/apps/compiler-ui/.next/static/XWKL548yXD_UOG4ID9G3J/_clientMiddlewareManifest.js +1 -0
- package/apps/compiler-ui/.next/static/XWKL548yXD_UOG4ID9G3J/_ssgManifest.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/03~yq9q893hmn.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/06z~l3kwb891e.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/08g7lvje.te.u.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/08m7vf5asqlsm.js +91 -0
- package/apps/compiler-ui/.next/static/chunks/0_i-3_5l9t2qe.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/0b-ywny_j0g~0.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/0b52v41o1gixx.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/0fgt_8knmicoz.js +124 -0
- package/apps/compiler-ui/.next/static/chunks/0gpzgsv0w.q~m.js +31 -0
- package/apps/compiler-ui/.next/static/chunks/0ilwfezfvu6~-.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/0n51hrfoufc7g.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/0ti_66mx7~w2-.js +5 -0
- package/apps/compiler-ui/.next/static/chunks/0xxmf45eskdt~.css +1 -0
- package/apps/compiler-ui/.next/static/chunks/0y5z3t-z1c8ks.js.map +5 -0
- package/apps/compiler-ui/.next/static/chunks/13g~4mamjft.c.css +3 -0
- package/apps/compiler-ui/.next/static/chunks/14wtz~vq25~qq.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/turbopack-109rtik40vwh5.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/turbopack-10e~t1yzi4svj.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/turbopack-worker-0sjn--fhq~1cg.js +1 -0
- package/apps/compiler-ui/.next/static/media/GeistMono_Variable.p.17jn9btb_52pq.woff2 +0 -0
- package/apps/compiler-ui/.next/static/media/Geist_Variable-s.p.0-te~ja_gpvcf.woff2 +0 -0
- package/apps/compiler-ui/.next/static/media/worker.102zas1s52_pf.js +109 -0
- package/builtin-workflows/interf/README.md +8 -8
- package/builtin-workflows/interf/compile/stages/shape/SKILL.md +4 -4
- package/builtin-workflows/interf/compile/stages/structure/SKILL.md +1 -1
- package/builtin-workflows/interf/improve/SKILL.md +1 -1
- package/builtin-workflows/interf/use/query/SKILL.md +1 -1
- package/builtin-workflows/interf/workflow.json +8 -8
- package/builtin-workflows/interf/workflow.schema.json +1 -1
- package/dist/cli/commands/check-draft.d.ts +5 -4
- package/dist/cli/commands/check-draft.js +18 -17
- package/dist/cli/commands/compile-controller.d.ts +3 -0
- package/dist/cli/commands/compile-controller.js +53 -45
- package/dist/cli/commands/compile.js +83 -27
- package/dist/cli/commands/compiled-flow.d.ts +3 -0
- package/dist/cli/commands/compiled-flow.js +9 -7
- package/dist/cli/commands/control-path.d.ts +11 -0
- package/dist/cli/commands/control-path.js +72 -0
- package/dist/cli/commands/create-workflow-wizard.d.ts +6 -0
- package/dist/cli/commands/create-workflow-wizard.js +191 -77
- package/dist/cli/commands/create.js +54 -40
- package/dist/cli/commands/default.js +4 -3
- package/dist/cli/commands/doctor.js +5 -5
- package/dist/cli/commands/executor-flow.js +1 -1
- package/dist/cli/commands/init.js +326 -76
- package/dist/cli/commands/list.js +8 -7
- package/dist/cli/commands/preparation-selection.d.ts +6 -0
- package/dist/cli/commands/preparation-selection.js +11 -0
- package/dist/cli/commands/reset.js +3 -3
- package/dist/cli/commands/source-config-wizard.d.ts +4 -3
- package/dist/cli/commands/source-config-wizard.js +175 -197
- package/dist/cli/commands/status.js +116 -8
- package/dist/cli/commands/test-flow.d.ts +1 -1
- package/dist/cli/commands/test-flow.js +31 -31
- package/dist/cli/commands/test.d.ts +4 -0
- package/dist/cli/commands/test.js +95 -58
- package/dist/cli/commands/verify.js +7 -7
- package/dist/cli/commands/web.d.ts +11 -0
- package/dist/cli/commands/web.js +373 -0
- package/dist/cli/index.d.ts +2 -1
- package/dist/cli/index.js +3 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/packages/agents/lib/execution.js +4 -2
- package/dist/packages/agents/lib/executors.d.ts +1 -0
- package/dist/packages/agents/lib/executors.js +1 -0
- package/dist/packages/agents/lib/render.d.ts +2 -2
- package/dist/packages/agents/lib/render.js +10 -9
- package/dist/packages/agents/lib/shells.d.ts +3 -11
- package/dist/packages/agents/lib/shells.js +45 -96
- package/dist/packages/agents/lib/types.d.ts +1 -0
- package/dist/packages/compiler/compiled-paths.d.ts +4 -1
- package/dist/packages/compiler/compiled-paths.js +7 -1
- package/dist/packages/compiler/compiled-pipeline.d.ts +7 -0
- package/dist/packages/compiler/compiled-pipeline.js +15 -4
- package/dist/packages/compiler/compiled-schema.js +1 -1
- package/dist/packages/compiler/compiled-stage-plan.d.ts +2 -2
- package/dist/packages/compiler/compiled-stage-plan.js +4 -4
- package/dist/packages/compiler/compiled-stage-runner.d.ts +5 -0
- package/dist/packages/compiler/compiled-stage-runner.js +50 -2
- package/dist/packages/compiler/compiled-target.d.ts +1 -1
- package/dist/packages/compiler/compiled-target.js +2 -2
- package/dist/packages/compiler/lib/schema.d.ts +161 -1
- package/dist/packages/compiler/lib/schema.js +87 -1
- package/dist/packages/compiler/raw-snapshot.d.ts +9 -2
- package/dist/packages/compiler/runtime-acceptance.js +1 -1
- package/dist/packages/compiler/runtime-contracts.js +2 -2
- package/dist/packages/compiler/runtime-prompt.js +6 -6
- package/dist/packages/compiler/runtime-reconcile.js +3 -3
- package/dist/packages/compiler/runtime-runs.js +3 -0
- package/dist/packages/compiler/runtime-types.d.ts +1 -0
- package/dist/packages/compiler/state-health.js +1 -1
- package/dist/packages/compiler/state-view.js +2 -2
- package/dist/packages/compiler/validate-compiled.js +11 -9
- package/dist/packages/execution/adapters.d.ts +15 -0
- package/dist/packages/execution/adapters.js +1 -0
- package/dist/packages/execution/events.d.ts +8 -0
- package/dist/packages/execution/events.js +16 -0
- package/dist/packages/execution/index.d.ts +9 -0
- package/dist/packages/execution/index.js +6 -0
- package/dist/packages/execution/lib/schema.d.ts +1554 -0
- package/dist/packages/execution/lib/schema.js +319 -0
- package/dist/packages/local-service/action-values.d.ts +23 -0
- package/dist/packages/local-service/action-values.js +31 -0
- package/dist/packages/local-service/client.d.ts +119 -0
- package/dist/packages/local-service/client.js +356 -0
- package/dist/packages/local-service/index.d.ts +15 -0
- package/dist/packages/local-service/index.js +11 -0
- package/dist/packages/local-service/lib/schema.d.ts +7355 -0
- package/dist/packages/local-service/lib/schema.js +636 -0
- package/dist/packages/local-service/routes.d.ts +27 -0
- package/dist/packages/local-service/routes.js +32 -0
- package/dist/packages/local-service/runtime.d.ts +134 -0
- package/dist/packages/local-service/runtime.js +2841 -0
- package/dist/packages/local-service/server.d.ts +17 -0
- package/dist/packages/local-service/server.js +572 -0
- package/dist/packages/project-model/index.d.ts +2 -1
- package/dist/packages/project-model/index.js +1 -0
- package/dist/packages/project-model/interf-detect.d.ts +6 -2
- package/dist/packages/project-model/interf-detect.js +25 -10
- package/dist/packages/project-model/interf-scaffold.js +9 -6
- package/dist/packages/project-model/interf.d.ts +1 -1
- package/dist/packages/project-model/interf.js +1 -1
- package/dist/packages/project-model/lib/schema.d.ts +80 -6
- package/dist/packages/project-model/lib/schema.js +29 -19
- package/dist/packages/project-model/source-config.d.ts +22 -13
- package/dist/packages/project-model/source-config.js +140 -123
- package/dist/packages/project-model/source-folders.d.ts +11 -0
- package/dist/packages/project-model/source-folders.js +110 -0
- package/dist/packages/testing/test-execution.js +5 -5
- package/dist/packages/testing/test-paths.js +1 -3
- package/dist/packages/workflow-authoring/workflow-authoring.d.ts +4 -6
- package/dist/packages/workflow-authoring/workflow-authoring.js +45 -86
- package/dist/packages/workflow-authoring/workflow-edit-session.d.ts +2 -0
- package/dist/packages/workflow-authoring/workflow-edit-session.js +80 -49
- package/dist/packages/workflow-authoring/workflow-improvement.js +2 -1
- package/dist/packages/workflow-package/context-interface.js +1 -1
- package/dist/packages/workflow-package/interf-workflow-package.d.ts +6 -0
- package/dist/packages/workflow-package/interf-workflow-package.js +115 -8
- package/dist/packages/workflow-package/local-workflows.js +33 -17
- package/dist/packages/workflow-package/workflow-definitions.d.ts +5 -5
- package/dist/packages/workflow-package/workflow-definitions.js +23 -22
- package/dist/packages/workflow-package/workflow-helpers.js +10 -6
- package/dist/packages/workflow-package/workflow-stage-runner.d.ts +1 -0
- package/dist/packages/workflow-package/workflow-stage-runner.js +2 -0
- package/package.json +17 -1
- package/dist/cli/commands/dataset-selection.d.ts +0 -6
- package/dist/cli/commands/dataset-selection.js +0 -11
- package/dist/lib/agent-args.d.ts +0 -1
- package/dist/lib/agent-args.js +0 -1
- package/dist/lib/agent-constants.d.ts +0 -1
- package/dist/lib/agent-constants.js +0 -1
- package/dist/lib/agent-detection.d.ts +0 -1
- package/dist/lib/agent-detection.js +0 -1
- package/dist/lib/agent-execution.d.ts +0 -1
- package/dist/lib/agent-execution.js +0 -1
- package/dist/lib/agent-logs.d.ts +0 -1
- package/dist/lib/agent-logs.js +0 -1
- package/dist/lib/agent-preflight.d.ts +0 -1
- package/dist/lib/agent-preflight.js +0 -1
- package/dist/lib/agent-render.d.ts +0 -1
- package/dist/lib/agent-render.js +0 -1
- package/dist/lib/agent-shells.d.ts +0 -1
- package/dist/lib/agent-shells.js +0 -1
- package/dist/lib/agent-status.d.ts +0 -1
- package/dist/lib/agent-status.js +0 -1
- package/dist/lib/agent-types.d.ts +0 -1
- package/dist/lib/agent-types.js +0 -1
- package/dist/lib/agents.d.ts +0 -1
- package/dist/lib/agents.js +0 -1
- package/dist/lib/builtin-compiled-workflow.d.ts +0 -1
- package/dist/lib/builtin-compiled-workflow.js +0 -1
- package/dist/lib/chart-guidance.d.ts +0 -1
- package/dist/lib/chart-guidance.js +0 -1
- package/dist/lib/compiled-compile.d.ts +0 -1
- package/dist/lib/compiled-compile.js +0 -1
- package/dist/lib/compiled-paths.d.ts +0 -1
- package/dist/lib/compiled-paths.js +0 -3
- package/dist/lib/compiled-raw.d.ts +0 -1
- package/dist/lib/compiled-raw.js +0 -3
- package/dist/lib/compiled-reset.d.ts +0 -1
- package/dist/lib/compiled-reset.js +0 -3
- package/dist/lib/compiled-schema.d.ts +0 -1
- package/dist/lib/compiled-schema.js +0 -1
- package/dist/lib/discovery.d.ts +0 -1
- package/dist/lib/discovery.js +0 -1
- package/dist/lib/execution-profile.d.ts +0 -1
- package/dist/lib/execution-profile.js +0 -1
- package/dist/lib/executors.d.ts +0 -1
- package/dist/lib/executors.js +0 -1
- package/dist/lib/filesystem.d.ts +0 -1
- package/dist/lib/filesystem.js +0 -1
- package/dist/lib/interf-bootstrap.d.ts +0 -1
- package/dist/lib/interf-bootstrap.js +0 -3
- package/dist/lib/interf-detect.d.ts +0 -1
- package/dist/lib/interf-detect.js +0 -3
- package/dist/lib/interf-scaffold.d.ts +0 -1
- package/dist/lib/interf-scaffold.js +0 -3
- package/dist/lib/interf-workflow-package.d.ts +0 -1
- package/dist/lib/interf-workflow-package.js +0 -1
- package/dist/lib/interf.d.ts +0 -1
- package/dist/lib/interf.js +0 -3
- package/dist/lib/local-workflows.d.ts +0 -1
- package/dist/lib/local-workflows.js +0 -1
- package/dist/lib/logger.d.ts +0 -1
- package/dist/lib/logger.js +0 -1
- package/dist/lib/package-root.d.ts +0 -1
- package/dist/lib/package-root.js +0 -1
- package/dist/lib/parse.d.ts +0 -1
- package/dist/lib/parse.js +0 -1
- package/dist/lib/project-paths.d.ts +0 -1
- package/dist/lib/project-paths.js +0 -3
- package/dist/lib/runtime-acceptance.d.ts +0 -1
- package/dist/lib/runtime-acceptance.js +0 -1
- package/dist/lib/runtime-contracts.d.ts +0 -1
- package/dist/lib/runtime-contracts.js +0 -1
- package/dist/lib/runtime-inventory.d.ts +0 -1
- package/dist/lib/runtime-inventory.js +0 -1
- package/dist/lib/runtime-paths.d.ts +0 -1
- package/dist/lib/runtime-paths.js +0 -1
- package/dist/lib/runtime-prompt.d.ts +0 -1
- package/dist/lib/runtime-prompt.js +0 -1
- package/dist/lib/runtime-reconcile.d.ts +0 -1
- package/dist/lib/runtime-reconcile.js +0 -1
- package/dist/lib/runtime-runs.d.ts +0 -1
- package/dist/lib/runtime-runs.js +0 -1
- package/dist/lib/runtime-types.d.ts +0 -1
- package/dist/lib/runtime-types.js +0 -1
- package/dist/lib/runtime.d.ts +0 -1
- package/dist/lib/runtime.js +0 -1
- package/dist/lib/schema.d.ts +0 -4
- package/dist/lib/schema.js +0 -6
- package/dist/lib/source-config.d.ts +0 -1
- package/dist/lib/source-config.js +0 -3
- package/dist/lib/state-artifacts.d.ts +0 -1
- package/dist/lib/state-artifacts.js +0 -1
- package/dist/lib/state-health.d.ts +0 -1
- package/dist/lib/state-health.js +0 -1
- package/dist/lib/state-io.d.ts +0 -1
- package/dist/lib/state-io.js +0 -1
- package/dist/lib/state-paths.d.ts +0 -1
- package/dist/lib/state-paths.js +0 -1
- package/dist/lib/state-view.d.ts +0 -1
- package/dist/lib/state-view.js +0 -1
- package/dist/lib/state.d.ts +0 -1
- package/dist/lib/state.js +0 -1
- package/dist/lib/test-execution.d.ts +0 -1
- package/dist/lib/test-execution.js +0 -3
- package/dist/lib/test-matrices.d.ts +0 -1
- package/dist/lib/test-matrices.js +0 -3
- package/dist/lib/test-paths.d.ts +0 -1
- package/dist/lib/test-paths.js +0 -3
- package/dist/lib/test-profile-presets.d.ts +0 -1
- package/dist/lib/test-profile-presets.js +0 -3
- package/dist/lib/test-sandbox.d.ts +0 -1
- package/dist/lib/test-sandbox.js +0 -3
- package/dist/lib/test-specs.d.ts +0 -1
- package/dist/lib/test-specs.js +0 -3
- package/dist/lib/test-targets.d.ts +0 -1
- package/dist/lib/test-targets.js +0 -3
- package/dist/lib/test-types.d.ts +0 -1
- package/dist/lib/test-types.js +0 -3
- package/dist/lib/test.d.ts +0 -1
- package/dist/lib/test.js +0 -3
- package/dist/lib/util.d.ts +0 -1
- package/dist/lib/util.js +0 -1
- package/dist/lib/validate-compiled.d.ts +0 -1
- package/dist/lib/validate-compiled.js +0 -1
- package/dist/lib/validate-helpers.d.ts +0 -1
- package/dist/lib/validate-helpers.js +0 -1
- package/dist/lib/validate.d.ts +0 -1
- package/dist/lib/validate.js +0 -1
- package/dist/lib/workflow-authoring.d.ts +0 -1
- package/dist/lib/workflow-authoring.js +0 -1
- package/dist/lib/workflow-definitions.d.ts +0 -1
- package/dist/lib/workflow-definitions.js +0 -1
- package/dist/lib/workflow-edit-session.d.ts +0 -1
- package/dist/lib/workflow-edit-session.js +0 -1
- package/dist/lib/workflow-edit-utils.d.ts +0 -1
- package/dist/lib/workflow-edit-utils.js +0 -1
- package/dist/lib/workflow-helpers.d.ts +0 -1
- package/dist/lib/workflow-helpers.js +0 -1
- package/dist/lib/workflow-improvement.d.ts +0 -1
- package/dist/lib/workflow-improvement.js +0 -1
- package/dist/lib/workflow-primitives.d.ts +0 -1
- package/dist/lib/workflow-primitives.js +0 -1
- package/dist/lib/workflow-review-paths.d.ts +0 -1
- package/dist/lib/workflow-review-paths.js +0 -1
- package/dist/lib/workflow-stage-policy.d.ts +0 -1
- package/dist/lib/workflow-stage-policy.js +0 -1
- package/dist/lib/workflow-stage-runner.d.ts +0 -1
- package/dist/lib/workflow-stage-runner.js +0 -1
- package/dist/lib/workflows.d.ts +0 -1
- package/dist/lib/workflows.js +0 -1
|
@@ -7,12 +7,12 @@ import { formatWorkflowExecutionProfile } from "../../packages/agents/lib/execut
|
|
|
7
7
|
function formatSavedDatasetHint(entry) {
|
|
8
8
|
const config = entry.config;
|
|
9
9
|
const checkCount = config.checks.length;
|
|
10
|
-
const workflowHint = `
|
|
10
|
+
const workflowHint = `Method ${config.method ?? config.workflow ?? "interf-default"}${entry.localDraft ? " (local draft)" : ""}`;
|
|
11
11
|
if (config.about)
|
|
12
12
|
return `${config.path} · ${config.about} · ${workflowHint}`;
|
|
13
13
|
if (checkCount === 0)
|
|
14
|
-
return `${config.path} · No
|
|
15
|
-
return `${config.path} · ${checkCount}
|
|
14
|
+
return `${config.path} · No readiness checks yet · ${workflowHint}`;
|
|
15
|
+
return `${config.path} · ${checkCount} readiness check${checkCount === 1 ? "" : "s"} · ${workflowHint}`;
|
|
16
16
|
}
|
|
17
17
|
export function listSavedCompiledEntries(sourcePath) {
|
|
18
18
|
const builtEntries = new Map();
|
|
@@ -57,7 +57,7 @@ export async function chooseCompiledConfigToBuild(options) {
|
|
|
57
57
|
label: entry.config.name,
|
|
58
58
|
hint: [
|
|
59
59
|
formatSavedDatasetHint(entry),
|
|
60
|
-
entry.path ? "
|
|
60
|
+
entry.path ? "Portable Context available" : "Portable Context not built yet",
|
|
61
61
|
].join(" · "),
|
|
62
62
|
})),
|
|
63
63
|
});
|
|
@@ -66,7 +66,7 @@ export async function chooseCompiledConfigToBuild(options) {
|
|
|
66
66
|
return savedEntries.find((entry) => entry.config.name === selected)?.config ?? null;
|
|
67
67
|
}
|
|
68
68
|
export function createCompiledFromConfig(sourcePath, datasetConfig) {
|
|
69
|
-
const workflowId = datasetConfig.workflow ?? "interf";
|
|
69
|
+
const workflowId = datasetConfig.method ?? datasetConfig.workflow ?? "interf-default";
|
|
70
70
|
const datasetSourcePath = resolveSourceDatasetPath(sourcePath, datasetConfig);
|
|
71
71
|
const compiledPath = createCompiled(datasetConfig.name, sourcePath, workflowId, datasetConfig.about, datasetSourcePath);
|
|
72
72
|
syncCompiledInterfConfigFromSourceDatasetConfig(compiledPath, datasetConfig);
|
|
@@ -82,7 +82,7 @@ export function ensureCompiledFromConfig(sourcePath, datasetConfig) {
|
|
|
82
82
|
}
|
|
83
83
|
export async function compileCompiledWithReporter(executor, compiledPath, options = {}) {
|
|
84
84
|
console.log();
|
|
85
|
-
console.log(chalk.bold(` ${options.heading ?? "Building
|
|
85
|
+
console.log(chalk.bold(` ${options.heading ?? "Building Portable Context..."}`));
|
|
86
86
|
const profileLabel = formatWorkflowExecutionProfile(executor.executionProfile);
|
|
87
87
|
if (profileLabel) {
|
|
88
88
|
console.log(chalk.dim(` Execution profile: ${profileLabel}`));
|
|
@@ -97,11 +97,13 @@ export async function compileCompiledWithReporter(executor, compiledPath, option
|
|
|
97
97
|
compiledPath,
|
|
98
98
|
reporter,
|
|
99
99
|
preserveStageShells: options.preserveStageShells,
|
|
100
|
+
runId: options.runId,
|
|
101
|
+
events: options.events,
|
|
100
102
|
});
|
|
101
103
|
if (!result.ok) {
|
|
102
104
|
return result;
|
|
103
105
|
}
|
|
104
106
|
console.log();
|
|
105
|
-
console.log(chalk.green(` ✓ ${options.successMessage ?? "Portable
|
|
107
|
+
console.log(chalk.green(` ✓ ${options.successMessage ?? "Portable Context ready."}`));
|
|
106
108
|
return result;
|
|
107
109
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function hasInterfInstanceConfig(controlPath: string): boolean;
|
|
2
|
+
export declare function findNearestInterfInstanceConfig(cwd?: string): string | null;
|
|
3
|
+
export declare function defaultInterfInstanceRoot(sourceFolderPath: string): string;
|
|
4
|
+
export declare function resolveCommandControlPath(cwd?: string): string;
|
|
5
|
+
export interface InterfInstanceContext {
|
|
6
|
+
controlPath: string;
|
|
7
|
+
defaultSourceFolderPath: string | null;
|
|
8
|
+
defaultPreparationPath: string | null;
|
|
9
|
+
}
|
|
10
|
+
export declare function relativeSourceFolderPath(controlPath: string, sourceFolderPath: string): string;
|
|
11
|
+
export declare function resolveInterfInstanceContext(cwd?: string): InterfInstanceContext;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { assertCompiledContainer } from "../../packages/project-model/interf.js";
|
|
5
|
+
import { sourceFolderConfigPath } from "../../packages/project-model/source-config.js";
|
|
6
|
+
function canUseInterfInstanceRoot(controlPath) {
|
|
7
|
+
try {
|
|
8
|
+
assertCompiledContainer(controlPath);
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function hasInterfInstanceConfig(controlPath) {
|
|
16
|
+
return existsSync(sourceFolderConfigPath(controlPath)) && canUseInterfInstanceRoot(controlPath);
|
|
17
|
+
}
|
|
18
|
+
export function findNearestInterfInstanceConfig(cwd = process.cwd()) {
|
|
19
|
+
let cursor = resolve(cwd);
|
|
20
|
+
while (true) {
|
|
21
|
+
if (hasInterfInstanceConfig(cursor))
|
|
22
|
+
return cursor;
|
|
23
|
+
const parentPath = dirname(cursor);
|
|
24
|
+
if (parentPath === cursor)
|
|
25
|
+
return null;
|
|
26
|
+
cursor = parentPath;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function fallbackInterfInstanceRoot(sourceFolderPath) {
|
|
30
|
+
return join(homedir(), ".interf", basename(sourceFolderPath) || "source-folder");
|
|
31
|
+
}
|
|
32
|
+
export function defaultInterfInstanceRoot(sourceFolderPath) {
|
|
33
|
+
const parentPath = dirname(sourceFolderPath);
|
|
34
|
+
if (parentPath !== sourceFolderPath && canUseInterfInstanceRoot(parentPath)) {
|
|
35
|
+
return parentPath;
|
|
36
|
+
}
|
|
37
|
+
return fallbackInterfInstanceRoot(sourceFolderPath);
|
|
38
|
+
}
|
|
39
|
+
export function resolveCommandControlPath(cwd = process.cwd()) {
|
|
40
|
+
const currentPath = resolve(cwd);
|
|
41
|
+
return findNearestInterfInstanceConfig(currentPath) ?? currentPath;
|
|
42
|
+
}
|
|
43
|
+
export function relativeSourceFolderPath(controlPath, sourceFolderPath) {
|
|
44
|
+
const relativePath = relative(controlPath, sourceFolderPath).split(sep).join("/") || ".";
|
|
45
|
+
if (relativePath.startsWith(".."))
|
|
46
|
+
return sourceFolderPath;
|
|
47
|
+
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
48
|
+
}
|
|
49
|
+
export function resolveInterfInstanceContext(cwd = process.cwd()) {
|
|
50
|
+
const currentPath = resolve(cwd);
|
|
51
|
+
const existingControlPath = findNearestInterfInstanceConfig(currentPath);
|
|
52
|
+
if (existingControlPath) {
|
|
53
|
+
if (existingControlPath !== currentPath) {
|
|
54
|
+
return {
|
|
55
|
+
controlPath: existingControlPath,
|
|
56
|
+
defaultSourceFolderPath: currentPath,
|
|
57
|
+
defaultPreparationPath: relativeSourceFolderPath(existingControlPath, currentPath),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
controlPath: currentPath,
|
|
62
|
+
defaultSourceFolderPath: null,
|
|
63
|
+
defaultPreparationPath: null,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const controlPath = defaultInterfInstanceRoot(currentPath);
|
|
67
|
+
return {
|
|
68
|
+
controlPath,
|
|
69
|
+
defaultSourceFolderPath: currentPath,
|
|
70
|
+
defaultPreparationPath: relativeSourceFolderPath(controlPath, currentPath),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -29,6 +29,7 @@ export interface WorkflowWizardDatasetContext {
|
|
|
29
29
|
datasetPath: string;
|
|
30
30
|
}
|
|
31
31
|
export declare const clackWorkflowPrompts: WorkflowWizardPrompts;
|
|
32
|
+
type WorkflowCreationMode = "draft-from-scratch" | "fork-existing" | "draft" | "manual";
|
|
32
33
|
export declare function formatWorkflowLabel(workflow: {
|
|
33
34
|
id: string;
|
|
34
35
|
label: string;
|
|
@@ -58,13 +59,18 @@ export declare function createWorkflowWizard(options?: {
|
|
|
58
59
|
intro?: boolean;
|
|
59
60
|
sourcePath?: string;
|
|
60
61
|
executionProfile?: WorkflowExecutionProfile;
|
|
62
|
+
baseWorkflowId?: string;
|
|
63
|
+
creationMode?: WorkflowCreationMode;
|
|
61
64
|
datasetContext?: WorkflowWizardDatasetContext;
|
|
62
65
|
resolveExecutor?: typeof resolveOrConfigureLocalExecutor;
|
|
63
66
|
runDraft?: typeof runWorkflowAuthoringDraft;
|
|
64
67
|
}, prompts?: WorkflowWizardPrompts): Promise<string | symbol | null>;
|
|
65
68
|
export declare function createCompiledWorkflowWizard(sourcePath: string, prompts?: WorkflowWizardPrompts, options?: {
|
|
66
69
|
executionProfile?: WorkflowExecutionProfile;
|
|
70
|
+
baseWorkflowId?: string;
|
|
71
|
+
creationMode?: WorkflowCreationMode;
|
|
67
72
|
datasetContext?: WorkflowWizardDatasetContext;
|
|
68
73
|
resolveExecutor?: typeof resolveOrConfigureLocalExecutor;
|
|
69
74
|
runDraft?: typeof runWorkflowAuthoringDraft;
|
|
70
75
|
}): Promise<string | symbol | null>;
|
|
76
|
+
export {};
|
|
@@ -9,6 +9,7 @@ import { resolveOrConfigureLocalExecutor } from "./executor-flow.js";
|
|
|
9
9
|
import { runWorkflowAuthoringDraft } from "../../packages/workflow-authoring/workflow-authoring.js";
|
|
10
10
|
import { listSourceDatasetConfigs, loadSourceFolderConfig, resolveSourceDatasetPath, } from "../../packages/project-model/source-config.js";
|
|
11
11
|
import { slugify } from "../../packages/shared/naming.js";
|
|
12
|
+
import { submitWorkflowAuthoringRunToLocalService } from "../../packages/local-service/index.js";
|
|
12
13
|
import { DEFAULT_DATASET_PATH_PLACEHOLDER, listDatasetFolderChoices, normalizeDatasetPathForConfig, } from "./source-config-wizard.js";
|
|
13
14
|
export const clackWorkflowPrompts = {
|
|
14
15
|
intro: p.intro,
|
|
@@ -20,6 +21,13 @@ export const clackWorkflowPrompts = {
|
|
|
20
21
|
error: p.log.error,
|
|
21
22
|
},
|
|
22
23
|
};
|
|
24
|
+
function normalizeWorkflowCreationMode(mode) {
|
|
25
|
+
if (mode === "draft")
|
|
26
|
+
return "draft-from-scratch";
|
|
27
|
+
if (mode === "manual")
|
|
28
|
+
return "fork-existing";
|
|
29
|
+
return mode;
|
|
30
|
+
}
|
|
23
31
|
function findMatchingDatasetConfig(sourcePath, datasetPath) {
|
|
24
32
|
const config = loadSourceFolderConfig(sourcePath);
|
|
25
33
|
for (const dataset of listSourceDatasetConfigs(config)) {
|
|
@@ -32,36 +40,46 @@ function findMatchingDatasetConfig(sourcePath, datasetPath) {
|
|
|
32
40
|
function describeSavedDataset(dataset) {
|
|
33
41
|
return dataset.about
|
|
34
42
|
? `${dataset.path} · ${dataset.about}`
|
|
35
|
-
: `${dataset.path} · ${dataset.checks.length}
|
|
43
|
+
: `${dataset.path} · ${dataset.checks.length} readiness check${dataset.checks.length === 1 ? "" : "s"}`;
|
|
36
44
|
}
|
|
37
45
|
async function promptWorkflowDatasetFolder(sourcePath, prompts) {
|
|
46
|
+
const savedDatasets = listSourceDatasetConfigs(loadSourceFolderConfig(sourcePath));
|
|
38
47
|
const folderChoices = listDatasetFolderChoices(sourcePath);
|
|
39
48
|
if (folderChoices.length > 0) {
|
|
40
49
|
const selected = await prompts.select({
|
|
41
|
-
message: "Which
|
|
50
|
+
message: "Which Source Folder should shape this Method?",
|
|
42
51
|
options: [
|
|
52
|
+
...savedDatasets.map((dataset) => ({
|
|
53
|
+
value: dataset.name,
|
|
54
|
+
label: dataset.name,
|
|
55
|
+
hint: describeSavedDataset(dataset),
|
|
56
|
+
})),
|
|
43
57
|
...folderChoices,
|
|
44
58
|
{
|
|
45
59
|
value: "__manual__",
|
|
46
60
|
label: "Enter a different path",
|
|
47
|
-
hint: "Use a relative path if the
|
|
61
|
+
hint: "Use a relative path if the Source Folder is not listed here",
|
|
48
62
|
},
|
|
49
63
|
],
|
|
50
64
|
});
|
|
51
65
|
if (prompts.isCancel(selected))
|
|
52
66
|
return selected;
|
|
53
67
|
if (selected !== "__manual__") {
|
|
68
|
+
const savedDataset = savedDatasets.find((dataset) => dataset.name === selected);
|
|
69
|
+
if (savedDataset) {
|
|
70
|
+
return resolveSourceDatasetPath(sourcePath, savedDataset);
|
|
71
|
+
}
|
|
54
72
|
return resolve(sourcePath, normalizeDatasetPathForConfig(sourcePath, String(selected)));
|
|
55
73
|
}
|
|
56
74
|
}
|
|
57
75
|
const datasetFolder = await prompts.text({
|
|
58
|
-
message: "Which
|
|
76
|
+
message: "Which Source Folder should shape this Method?",
|
|
59
77
|
placeholder: DEFAULT_DATASET_PATH_PLACEHOLDER,
|
|
60
78
|
initialValue: folderChoices.length === 1 ? folderChoices[0]?.value : undefined,
|
|
61
79
|
validate: (value) => {
|
|
62
80
|
const trimmed = value.trim();
|
|
63
81
|
if (trimmed.length === 0)
|
|
64
|
-
return "Source
|
|
82
|
+
return "Source Folder is required";
|
|
65
83
|
try {
|
|
66
84
|
normalizeDatasetPathForConfig(sourcePath, trimmed);
|
|
67
85
|
return undefined;
|
|
@@ -85,6 +103,15 @@ export function formatWorkflowLabel(workflow) {
|
|
|
85
103
|
export function buildCompiledWorkflowOptions(sourcePath) {
|
|
86
104
|
return listCompiledWorkflowChoices(sourcePath).map(formatWorkflowLabel);
|
|
87
105
|
}
|
|
106
|
+
function workflowUseLabel(workflow) {
|
|
107
|
+
if (workflow.value === "interf-default" || workflow.value === "interf") {
|
|
108
|
+
return "built-in Method";
|
|
109
|
+
}
|
|
110
|
+
return workflow.label.replace(/ \(Local\)$/, "");
|
|
111
|
+
}
|
|
112
|
+
function workflowForkLabel(workflow) {
|
|
113
|
+
return `Fork ${workflowUseLabel(workflow)}`;
|
|
114
|
+
}
|
|
88
115
|
export async function chooseCompiledWorkflow(sourcePath, options = {}) {
|
|
89
116
|
const currentWorkflowId = options.currentWorkflowId;
|
|
90
117
|
const workflowOptions = buildCompiledWorkflowOptions(sourcePath);
|
|
@@ -107,50 +134,77 @@ export async function chooseCompiledWorkflow(sourcePath, options = {}) {
|
|
|
107
134
|
return orderedOptions[0]?.value ?? "interf";
|
|
108
135
|
}
|
|
109
136
|
return p.select({
|
|
110
|
-
message: options.message ?? "
|
|
137
|
+
message: options.message ?? "Preparation Method?",
|
|
111
138
|
options: orderedOptions,
|
|
112
139
|
});
|
|
113
140
|
}
|
|
114
141
|
export async function chooseOrCreateCompiledWorkflowForDataset(sourcePath, datasetConfig, options = {}, prompts = clackWorkflowPrompts) {
|
|
115
|
-
seedLocalDefaultWorkflow({ sourcePath });
|
|
116
142
|
const currentWorkflowId = options.currentWorkflowId ?? datasetConfig.workflow ?? "interf-default";
|
|
117
|
-
const
|
|
118
|
-
|
|
143
|
+
const allWorkflowOptions = buildCompiledWorkflowOptions(sourcePath);
|
|
144
|
+
const workflowOptions = allWorkflowOptions.filter((workflow) => workflow.value !== "interf");
|
|
145
|
+
const builtinDefault = allWorkflowOptions.find((workflow) => workflow.value === "interf");
|
|
146
|
+
const virtualDefaultWorkflow = builtinDefault
|
|
147
|
+
? {
|
|
148
|
+
value: "interf-default",
|
|
149
|
+
label: "built-in Method",
|
|
150
|
+
hint: "Use the built-in Method without drafting a custom package",
|
|
151
|
+
}
|
|
152
|
+
: undefined;
|
|
119
153
|
const currentWorkflow = workflowOptions.find((workflow) => workflow.value === currentWorkflowId) ??
|
|
120
154
|
workflowOptions.find((workflow) => workflow.value === "interf-default") ??
|
|
155
|
+
(currentWorkflowId === "interf-default" ? virtualDefaultWorkflow : undefined) ??
|
|
121
156
|
workflowOptions[0];
|
|
122
157
|
const selected = await prompts.select({
|
|
123
|
-
message: "
|
|
158
|
+
message: "Which Method should Interf use for this Preparation?",
|
|
124
159
|
options: [
|
|
160
|
+
{
|
|
161
|
+
value: "__draft_from_scratch__",
|
|
162
|
+
label: "Draft a new Method from scratch (Recommended)",
|
|
163
|
+
hint: "Start from a neutral scaffold; an agent designs stages, outputs, and proof for this Preparation",
|
|
164
|
+
},
|
|
125
165
|
...(currentWorkflow
|
|
126
166
|
? [{
|
|
127
167
|
value: "__current__",
|
|
128
|
-
label: `Use ${currentWorkflow
|
|
129
|
-
hint: currentWorkflow.
|
|
168
|
+
label: `Use ${workflowUseLabel(currentWorkflow)}`,
|
|
169
|
+
hint: currentWorkflow.value === "interf-default"
|
|
170
|
+
? "Use the built-in Method without drafting a custom package"
|
|
171
|
+
: currentWorkflow.hint,
|
|
172
|
+
}]
|
|
173
|
+
: []),
|
|
174
|
+
...(currentWorkflow
|
|
175
|
+
? [{
|
|
176
|
+
value: "__fork_existing__",
|
|
177
|
+
label: workflowForkLabel(currentWorkflow),
|
|
178
|
+
hint: "Copy its existing stage topology, then write the per-stage guidance yourself",
|
|
130
179
|
}]
|
|
131
180
|
: []),
|
|
132
|
-
{
|
|
133
|
-
value: "__create__",
|
|
134
|
-
label: "Create a workflow for this setup",
|
|
135
|
-
hint: "Draft a file-processing workflow from this source folder, work description, and questions",
|
|
136
|
-
},
|
|
137
181
|
...workflowOptions
|
|
138
182
|
.filter((workflow) => workflow.value !== currentWorkflow?.value)
|
|
139
183
|
.map((workflow) => ({
|
|
140
184
|
...workflow,
|
|
141
|
-
label: `Use ${workflow
|
|
185
|
+
label: `Use ${workflowUseLabel(workflow)}`,
|
|
142
186
|
})),
|
|
143
187
|
],
|
|
144
188
|
});
|
|
145
189
|
if (prompts.isCancel(selected))
|
|
146
190
|
return selected;
|
|
147
191
|
if (selected === "__current__") {
|
|
192
|
+
if (currentWorkflow?.value === "interf-default") {
|
|
193
|
+
seedLocalDefaultWorkflow({ sourcePath });
|
|
194
|
+
}
|
|
148
195
|
return currentWorkflow?.value ?? currentWorkflowId;
|
|
149
196
|
}
|
|
150
|
-
if (selected === "
|
|
197
|
+
if (selected === "__draft_from_scratch__" || selected === "__fork_existing__") {
|
|
198
|
+
if (selected === "__fork_existing__" && currentWorkflow?.value === "interf-default") {
|
|
199
|
+
seedLocalDefaultWorkflow({ sourcePath });
|
|
200
|
+
}
|
|
151
201
|
const workflowId = await createWorkflowWizard({
|
|
152
202
|
intro: false,
|
|
153
203
|
sourcePath,
|
|
204
|
+
baseWorkflowId: selected === "__fork_existing__"
|
|
205
|
+
? currentWorkflow?.value ?? currentWorkflowId
|
|
206
|
+
: undefined,
|
|
207
|
+
creationMode: selected === "__draft_from_scratch__" ? "draft-from-scratch" : "fork-existing",
|
|
154
208
|
executionProfile: options.executionProfile,
|
|
155
209
|
resolveExecutor: options.resolveExecutor,
|
|
156
210
|
runDraft: options.runDraft,
|
|
@@ -165,43 +219,51 @@ export async function chooseOrCreateCompiledWorkflowForDataset(sourcePath, datas
|
|
|
165
219
|
}
|
|
166
220
|
export async function createWorkflowWizard(options = {}, prompts = clackWorkflowPrompts) {
|
|
167
221
|
if (options.intro !== false) {
|
|
168
|
-
prompts.intro(chalk.bold("Create a
|
|
222
|
+
prompts.intro(chalk.bold("Create a Method"));
|
|
169
223
|
}
|
|
170
224
|
const sourcePath = options.sourcePath ?? process.cwd();
|
|
171
225
|
return createCompiledWorkflowWizard(sourcePath, prompts, {
|
|
172
226
|
executionProfile: options.executionProfile,
|
|
227
|
+
baseWorkflowId: options.baseWorkflowId,
|
|
228
|
+
creationMode: options.creationMode,
|
|
173
229
|
datasetContext: options.datasetContext,
|
|
174
230
|
resolveExecutor: options.resolveExecutor,
|
|
175
231
|
runDraft: options.runDraft,
|
|
176
232
|
});
|
|
177
233
|
}
|
|
178
234
|
export async function createCompiledWorkflowWizard(sourcePath, prompts = clackWorkflowPrompts, options = {}) {
|
|
179
|
-
const
|
|
180
|
-
message: "Start from which existing workflow?",
|
|
181
|
-
options: listCompiledWorkflowChoices(sourcePath).map(formatWorkflowLabel),
|
|
182
|
-
});
|
|
183
|
-
if (prompts.isCancel(baseWorkflow))
|
|
184
|
-
return baseWorkflow;
|
|
185
|
-
const resolvedBaseWorkflow = getCompiledWorkflow(String(baseWorkflow), { sourcePath });
|
|
186
|
-
const creationMode = await prompts.select({
|
|
235
|
+
const creationMode = options.creationMode ?? await prompts.select({
|
|
187
236
|
message: "How do you want to create it?",
|
|
188
237
|
options: [
|
|
189
238
|
{
|
|
190
|
-
value: "draft",
|
|
191
|
-
label: "Draft a
|
|
192
|
-
hint: "
|
|
239
|
+
value: "draft-from-scratch",
|
|
240
|
+
label: "Draft a new Method from scratch (Recommended)",
|
|
241
|
+
hint: "Start from a neutral scaffold and let a local agent design a reusable Method for this kind of agent work",
|
|
193
242
|
},
|
|
194
243
|
{
|
|
195
|
-
value: "
|
|
196
|
-
label: "
|
|
197
|
-
hint: "
|
|
244
|
+
value: "fork-existing",
|
|
245
|
+
label: "Fork an existing Method and edit stage guidance",
|
|
246
|
+
hint: "Copy an existing topology; choose this when the stages are right but their emphasis should change",
|
|
198
247
|
},
|
|
199
248
|
],
|
|
200
249
|
});
|
|
201
250
|
if (prompts.isCancel(creationMode))
|
|
202
251
|
return creationMode;
|
|
252
|
+
const creationModeValue = normalizeWorkflowCreationMode(creationMode);
|
|
253
|
+
const baseWorkflow = creationModeValue === "fork-existing"
|
|
254
|
+
? options.baseWorkflowId ?? await prompts.select({
|
|
255
|
+
message: "Which existing Method should Interf fork?",
|
|
256
|
+
options: listCompiledWorkflowChoices(sourcePath).map(formatWorkflowLabel),
|
|
257
|
+
})
|
|
258
|
+
: null;
|
|
259
|
+
if (prompts.isCancel(baseWorkflow))
|
|
260
|
+
return baseWorkflow;
|
|
261
|
+
const baseWorkflowId = typeof baseWorkflow === "string" ? baseWorkflow : null;
|
|
262
|
+
const resolvedBaseWorkflow = baseWorkflowId
|
|
263
|
+
? getCompiledWorkflow(baseWorkflowId, { sourcePath })
|
|
264
|
+
: null;
|
|
203
265
|
const rawName = await prompts.text({
|
|
204
|
-
message: "New
|
|
266
|
+
message: "New Method name?",
|
|
205
267
|
placeholder: "customer-research",
|
|
206
268
|
validate: (value) => {
|
|
207
269
|
if (value.trim().length === 0)
|
|
@@ -210,7 +272,7 @@ export async function createCompiledWorkflowWizard(sourcePath, prompts = clackWo
|
|
|
210
272
|
if (!isWorkflowId(workflowId))
|
|
211
273
|
return "Use letters, numbers, and dashes only";
|
|
212
274
|
if (listCompiledWorkflowChoices(sourcePath).some((workflow) => workflow.id === workflowId)) {
|
|
213
|
-
return "That
|
|
275
|
+
return "That Method name already exists";
|
|
214
276
|
}
|
|
215
277
|
return undefined;
|
|
216
278
|
},
|
|
@@ -220,20 +282,20 @@ export async function createCompiledWorkflowWizard(sourcePath, prompts = clackWo
|
|
|
220
282
|
const workflowId = slugify(rawName);
|
|
221
283
|
const label = rawName.trim();
|
|
222
284
|
const hint = await prompts.text({
|
|
223
|
-
message: "One-line
|
|
285
|
+
message: "One-line Method description?",
|
|
224
286
|
placeholder: "Bias toward evidence-backed summaries and strong retrieval structure",
|
|
225
287
|
validate: (value) => (value.trim().length === 0 ? "Description is required" : undefined),
|
|
226
288
|
});
|
|
227
289
|
if (prompts.isCancel(hint))
|
|
228
290
|
return hint;
|
|
229
|
-
if (
|
|
291
|
+
if (creationModeValue === "draft-from-scratch") {
|
|
230
292
|
let datasetPath = options.datasetContext?.datasetPath ?? null;
|
|
231
293
|
let matchedDataset = options.datasetContext?.config ?? null;
|
|
232
294
|
if (!datasetPath) {
|
|
233
295
|
const savedDatasets = listSourceDatasetConfigs(loadSourceFolderConfig(sourcePath));
|
|
234
296
|
if (savedDatasets.length > 0) {
|
|
235
297
|
const datasetChoice = await prompts.select({
|
|
236
|
-
message: "Which
|
|
298
|
+
message: "Which saved Preparation should shape this Method?",
|
|
237
299
|
options: [
|
|
238
300
|
...savedDatasets.map((dataset) => ({
|
|
239
301
|
value: dataset.name,
|
|
@@ -243,7 +305,7 @@ export async function createCompiledWorkflowWizard(sourcePath, prompts = clackWo
|
|
|
243
305
|
{
|
|
244
306
|
value: "__manual__",
|
|
245
307
|
label: "Enter folder path manually",
|
|
246
|
-
hint: "Use a folder that is not saved as a
|
|
308
|
+
hint: "Use a folder that is not saved as a Preparation yet",
|
|
247
309
|
},
|
|
248
310
|
],
|
|
249
311
|
});
|
|
@@ -267,48 +329,97 @@ export async function createCompiledWorkflowWizard(sourcePath, prompts = clackWo
|
|
|
267
329
|
matchedDataset = matchedDataset ?? findMatchingDatasetConfig(sourcePath, datasetPath);
|
|
268
330
|
}
|
|
269
331
|
const taskPrompt = await prompts.text({
|
|
270
|
-
message: "What should this
|
|
271
|
-
placeholder: "Data: research interviews. Output: per-file summaries, themes, entities, claims, and source links.
|
|
332
|
+
message: "What should this Method prepare for agents, and what evidence should show the data is ready?",
|
|
333
|
+
placeholder: "Data: research interviews. Output: per-file summaries, themes, entities, claims, and source links. Evidence: every file processed, evidence linked to sources, required outputs created.",
|
|
272
334
|
validate: (value) => (value.trim().length === 0 ? "A description is required" : undefined),
|
|
273
335
|
});
|
|
274
336
|
if (prompts.isCancel(taskPrompt))
|
|
275
337
|
return taskPrompt;
|
|
276
338
|
if (matchedDataset) {
|
|
277
|
-
prompts.log.info(`Shaping this
|
|
339
|
+
prompts.log.info(`Shaping this Method from Preparation "${matchedDataset.name}".`);
|
|
278
340
|
}
|
|
279
341
|
if (matchedDataset?.checks.length) {
|
|
280
|
-
prompts.log.info(`Using ${matchedDataset.checks.length} saved
|
|
342
|
+
prompts.log.info(`Using ${matchedDataset.checks.length} saved readiness check${matchedDataset.checks.length === 1 ? "" : "s"} from Preparation "${matchedDataset.name}" as authoring context.`);
|
|
281
343
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
344
|
+
prompts.log.info("Preparing a Method-authoring shell from the Source Folder, then drafting the package.");
|
|
345
|
+
let lastServiceStatus = "";
|
|
346
|
+
const serviceRun = await submitWorkflowAuthoringRunToLocalService({
|
|
347
|
+
projectPath: sourcePath,
|
|
348
|
+
request: {
|
|
349
|
+
preparation: matchedDataset?.name ?? null,
|
|
350
|
+
source_folder_path: datasetPath,
|
|
351
|
+
method_id: workflowId,
|
|
352
|
+
label,
|
|
353
|
+
hint: hint.trim(),
|
|
354
|
+
task_prompt: taskPrompt.trim(),
|
|
355
|
+
checks: matchedDataset?.checks ?? [],
|
|
356
|
+
},
|
|
357
|
+
onSubmitted: (submission) => {
|
|
358
|
+
prompts.log.info(`Visible in Interf: ${submission.serviceUrl}/`);
|
|
359
|
+
},
|
|
360
|
+
onUpdate: (job) => {
|
|
361
|
+
const activeStep = job.steps.find((step) => step.status === "running")
|
|
362
|
+
?? [...job.steps].reverse().find((step) => step.status === "succeeded" || step.status === "failed")
|
|
363
|
+
?? null;
|
|
364
|
+
const statusKey = `${job.status}:${activeStep?.id ?? ""}:${activeStep?.status ?? ""}`;
|
|
365
|
+
if (statusKey === lastServiceStatus)
|
|
366
|
+
return;
|
|
367
|
+
lastServiceStatus = statusKey;
|
|
368
|
+
prompts.log.info(activeStep
|
|
369
|
+
? `${activeStep.label}: ${activeStep.status}`
|
|
370
|
+
: `Method draft run: ${job.status}`);
|
|
371
|
+
},
|
|
287
372
|
});
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
373
|
+
const result = serviceRun
|
|
374
|
+
? serviceRun.result
|
|
375
|
+
? {
|
|
376
|
+
status: serviceRun.result.status,
|
|
377
|
+
changed: serviceRun.result.changed,
|
|
378
|
+
summary: serviceRun.result.summary,
|
|
379
|
+
validation: serviceRun.result.validation ?? null,
|
|
380
|
+
workflowPath: serviceRun.result.method_path,
|
|
381
|
+
shellPath: serviceRun.result.shell_path,
|
|
382
|
+
}
|
|
383
|
+
: {
|
|
384
|
+
status: "executor-failed",
|
|
385
|
+
changed: false,
|
|
386
|
+
summary: serviceRun.error ?? "Method authoring failed in the local Interf service.",
|
|
387
|
+
validation: null,
|
|
388
|
+
workflowPath: resolve(sourcePath, "interf", "methods", workflowId),
|
|
389
|
+
shellPath: resolve(sourcePath, "interf", "methods", workflowId),
|
|
390
|
+
}
|
|
391
|
+
: await (async () => {
|
|
392
|
+
const resolveExecutor = options.resolveExecutor ?? resolveOrConfigureLocalExecutor;
|
|
393
|
+
const runDraft = options.runDraft ?? runWorkflowAuthoringDraft;
|
|
394
|
+
const { executor, error } = await resolveExecutor({
|
|
395
|
+
executionProfile: options.executionProfile,
|
|
396
|
+
purpose: "workflow",
|
|
397
|
+
});
|
|
398
|
+
if (!executor && !error) {
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
if (!executor) {
|
|
402
|
+
process.exitCode = 1;
|
|
403
|
+
(prompts.log.error ?? prompts.log.info)(error ?? "No coding agent detected.");
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
return runDraft({
|
|
407
|
+
sourcePath,
|
|
408
|
+
datasetPath,
|
|
409
|
+
workflowId,
|
|
410
|
+
label,
|
|
411
|
+
hint: hint.trim(),
|
|
412
|
+
taskPrompt: taskPrompt.trim(),
|
|
413
|
+
checks: matchedDataset?.checks ?? [],
|
|
414
|
+
executor,
|
|
415
|
+
onStatus: (line) => prompts.log.info(line),
|
|
416
|
+
});
|
|
417
|
+
})();
|
|
418
|
+
if (!result)
|
|
294
419
|
return null;
|
|
295
|
-
}
|
|
296
|
-
prompts.log.info("Preparing a workflow-authoring preview from the source folder, then drafting the package.");
|
|
297
|
-
const result = await runDraft({
|
|
298
|
-
sourcePath,
|
|
299
|
-
datasetPath,
|
|
300
|
-
baseWorkflowId: baseWorkflow,
|
|
301
|
-
workflowId,
|
|
302
|
-
label,
|
|
303
|
-
hint: hint.trim(),
|
|
304
|
-
taskPrompt: taskPrompt.trim(),
|
|
305
|
-
checks: matchedDataset?.checks ?? [],
|
|
306
|
-
executor,
|
|
307
|
-
preparePreview: true,
|
|
308
|
-
});
|
|
309
420
|
if (result.status === "updated") {
|
|
310
421
|
const draft = loadWorkflowDefinitionFromDir(result.workflowPath);
|
|
311
|
-
const stageList = draft?.stages?.map((stage) => stage.id).join("
|
|
422
|
+
const stageList = draft?.stages?.map((stage) => stage.id).join(" -> ") ?? "-";
|
|
312
423
|
prompts.log.info(`Draft ready at ${result.workflowPath}`);
|
|
313
424
|
prompts.log.info(` Name: ${draft?.label ?? label}`);
|
|
314
425
|
prompts.log.info(` Description: ${draft?.hint ?? hint.trim()}`);
|
|
@@ -316,9 +427,9 @@ export async function createCompiledWorkflowWizard(sourcePath, prompts = clackWo
|
|
|
316
427
|
prompts.log.info(` Purpose: ${draft.purpose}`);
|
|
317
428
|
prompts.log.info(` Stages: ${stageList}`);
|
|
318
429
|
const confirmChoice = await prompts.select({
|
|
319
|
-
message: "Save this
|
|
430
|
+
message: "Save this Method?",
|
|
320
431
|
options: [
|
|
321
|
-
{ value: "save", label: "Save", hint: "Keep the draft as your new
|
|
432
|
+
{ value: "save", label: "Save", hint: "Keep the draft as your new Method package" },
|
|
322
433
|
{ value: "cancel", label: "Discard", hint: "Remove the draft folder and exit without saving" },
|
|
323
434
|
],
|
|
324
435
|
});
|
|
@@ -327,17 +438,20 @@ export async function createCompiledWorkflowWizard(sourcePath, prompts = clackWo
|
|
|
327
438
|
prompts.log.info(`Discarded draft at ${result.workflowPath}`);
|
|
328
439
|
return null;
|
|
329
440
|
}
|
|
330
|
-
prompts.log.info(`Saved local
|
|
441
|
+
prompts.log.info(`Saved local Method: ${result.workflowPath}`);
|
|
331
442
|
return workflowId;
|
|
332
443
|
}
|
|
333
444
|
process.exitCode = 1;
|
|
334
445
|
(prompts.log.error ?? prompts.log.info)(result.status === "no-change"
|
|
335
|
-
? `${result.summary} Draft mode only succeeds when it produces
|
|
446
|
+
? `${result.summary} Draft mode only succeeds when it produces an agent-work-specific package change.`
|
|
336
447
|
: result.summary);
|
|
337
|
-
prompts.log.info(`
|
|
448
|
+
prompts.log.info(`Method shell kept at: ${result.shellPath}`);
|
|
338
449
|
return null;
|
|
339
450
|
}
|
|
340
451
|
const stagePolicyNotes = {};
|
|
452
|
+
if (!baseWorkflowId || !resolvedBaseWorkflow) {
|
|
453
|
+
throw new Error("Fork-existing Method creation needs a base Method.");
|
|
454
|
+
}
|
|
341
455
|
for (const stage of resolvedBaseWorkflow.stages) {
|
|
342
456
|
const stagePrompt = await prompts.text({
|
|
343
457
|
message: `What should ${stage.id} (${stage.label}) emphasize?`,
|
|
@@ -350,12 +464,12 @@ export async function createCompiledWorkflowWizard(sourcePath, prompts = clackWo
|
|
|
350
464
|
}
|
|
351
465
|
const workflowPath = createLocalWorkflowPackageFromTemplate({
|
|
352
466
|
sourcePath,
|
|
353
|
-
baseWorkflowId
|
|
467
|
+
baseWorkflowId,
|
|
354
468
|
workflowId,
|
|
355
469
|
label,
|
|
356
470
|
hint: hint.trim(),
|
|
357
471
|
stagePolicyNotes,
|
|
358
472
|
});
|
|
359
|
-
prompts.log.info(`Saved local
|
|
473
|
+
prompts.log.info(`Saved local Method: ${workflowPath}`);
|
|
360
474
|
return workflowId;
|
|
361
475
|
}
|