@formigio/fazemos-cli 0.10.12 → 0.10.13
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/dist/index.js +97 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2469,14 +2469,58 @@ commitments
|
|
|
2469
2469
|
process.exit(1);
|
|
2470
2470
|
}
|
|
2471
2471
|
});
|
|
2472
|
+
// [F24 §3.6 / R16-R20] cm reopen — Restore an open state on a closed
|
|
2473
|
+
// commitment. The close event stays in the audit trail (a new audit_log
|
|
2474
|
+
// row records the reopen with from_state and to_state='open'). Agents
|
|
2475
|
+
// cannot reopen — the API's permission predicate naturally excludes
|
|
2476
|
+
// service principals (requireMemberId throws when req.member.id is null).
|
|
2477
|
+
commitments
|
|
2478
|
+
.command('reopen <id>')
|
|
2479
|
+
.description('Restore an open state on a closed commitment. The close event stays in the audit trail.')
|
|
2480
|
+
.option('--reason <text>', 'Optional human-readable note for the audit log (max 500 chars)')
|
|
2481
|
+
.option('--json', 'Print the raw API response as JSON (machine-readable)')
|
|
2482
|
+
.action(async (id, opts) => {
|
|
2483
|
+
try {
|
|
2484
|
+
const body = {};
|
|
2485
|
+
if (opts.reason)
|
|
2486
|
+
body.reason = opts.reason;
|
|
2487
|
+
const data = await api('PATCH', `/api/commitments/${id}/reopen`, body);
|
|
2488
|
+
if (opts.json) {
|
|
2489
|
+
console.log(JSON.stringify(data, null, 2));
|
|
2490
|
+
return;
|
|
2491
|
+
}
|
|
2492
|
+
if (data.noop) {
|
|
2493
|
+
console.log(chalk.yellow('This commitment is already open. Nothing to reopen.'));
|
|
2494
|
+
return;
|
|
2495
|
+
}
|
|
2496
|
+
const c = data.commitment;
|
|
2497
|
+
const prev = data.previousCompletedAt;
|
|
2498
|
+
const prevFmt = prev ? new Date(prev).toISOString().slice(0, 16).replace('T', ' ') : null;
|
|
2499
|
+
const tail = prevFmt ? ` The close on ${prevFmt} stays in the audit trail.` : '';
|
|
2500
|
+
console.log(chalk.green(`Reopened. Commitment ${c.id} is open again.${tail}`));
|
|
2501
|
+
}
|
|
2502
|
+
catch (err) {
|
|
2503
|
+
console.error(chalk.red(err.message));
|
|
2504
|
+
process.exit(1);
|
|
2505
|
+
}
|
|
2506
|
+
});
|
|
2507
|
+
// [F24 §3.4 / R13-R14] cm execute — gained `--repos` option for
|
|
2508
|
+
// commitment-source clone overrides (mirrors the top-level execute flag).
|
|
2509
|
+
// The server-side endpoint now reads agent_config.repos as a fallback
|
|
2510
|
+
// when no body.repos is supplied; this CLI flag is the operator-side
|
|
2511
|
+
// override for `fazemos cm execute -w <ws> -c <cm> --repos <repos>`.
|
|
2472
2512
|
commitments
|
|
2473
2513
|
.command('execute')
|
|
2474
2514
|
.description('Trigger an agent execution for a commitment. The API determines which agent to use based on the commitment\'s configuration. For more control, use the top-level "execute" command instead.')
|
|
2475
2515
|
.requiredOption('-w, --worksheet <id>', 'Worksheet ID')
|
|
2476
2516
|
.requiredOption('-c, --commitment <id>', 'Commitment ID (from "cm list" or "ws show" output)')
|
|
2517
|
+
.option('--repos <repos>', 'Comma-separated repo names to clone for this execution (overrides the agent\'s default agent_config.repos)', (v) => v.split(','))
|
|
2477
2518
|
.action(async (opts) => {
|
|
2478
2519
|
try {
|
|
2479
|
-
const
|
|
2520
|
+
const body = {};
|
|
2521
|
+
if (opts.repos)
|
|
2522
|
+
body.repos = opts.repos;
|
|
2523
|
+
const data = await api('POST', `/api/worksheets/${opts.worksheet}/commitments/${opts.commitment}/execute`, body);
|
|
2480
2524
|
console.log(chalk.green('Execution triggered'));
|
|
2481
2525
|
if (data.execution?.id)
|
|
2482
2526
|
console.log(` Execution ID: ${data.execution.id}`);
|
|
@@ -4721,7 +4765,8 @@ program
|
|
|
4721
4765
|
.argument('<source-id>', 'Action, commitment, or pipeline step ID')
|
|
4722
4766
|
.requiredOption('--agent <name>', 'Agent name or member ID')
|
|
4723
4767
|
.option('--source-type <type>', 'Source type (action, commitment, pipeline_step)', 'action')
|
|
4724
|
-
.option('--prompt <prompt>', '
|
|
4768
|
+
.option('--prompt <prompt>', 'Operator instructions for this execution. Appended to the agent\'s built prompt as a labeled "## Operator Instructions" section. Takes precedence over runtime auto-completion instructions per the precedence rule (see architecture doc).')
|
|
4769
|
+
.option('--no-auto-complete', 'Suppress the runtime auto-completion instruction. The agent will not be told to mark the source done. Use this for "draft, don\'t close" workflows where a human reviews and locks. Default: off. Pipeline-step source: ignored with a warning.')
|
|
4725
4770
|
.option('--repos <repos>', 'Comma-separated repo names to clone (overrides agent config)', (v) => v.split(','))
|
|
4726
4771
|
.option('--model <model>', 'Model override (e.g., opus, sonnet)')
|
|
4727
4772
|
.option('--budget <usd>', 'Max budget override in USD', parseNumber)
|
|
@@ -4732,6 +4777,22 @@ program
|
|
|
4732
4777
|
console.error(chalk.red(`Invalid source type. Must be one of: ${validTypes.join(', ')}`));
|
|
4733
4778
|
process.exit(1);
|
|
4734
4779
|
}
|
|
4780
|
+
// [F24 §3.3 / EC3 / rul_no_auto_complete_pipeline_step_ignored]
|
|
4781
|
+
// --no-auto-complete is ignored for pipeline_step sources to preserve
|
|
4782
|
+
// back-compat for shipped pipeline executions. Layer-1 defense:
|
|
4783
|
+
// CLI prints a warning and does NOT forward the flag onto
|
|
4784
|
+
// context.noAutoComplete. Layer-2 defense lives in the agent's
|
|
4785
|
+
// buildSelfReportingInstructions, which gates the noAutoComplete
|
|
4786
|
+
// check on source_type !== 'pipeline_step' regardless.
|
|
4787
|
+
//
|
|
4788
|
+
// commander.js: `--no-auto-complete` produces opts.autoComplete=false
|
|
4789
|
+
// (NOT opts.noAutoComplete=true) because of the `--no-` prefix
|
|
4790
|
+
// convention. We surface that as the boolean `forwardSuppress` below.
|
|
4791
|
+
const operatorOptedOut = opts.autoComplete === false;
|
|
4792
|
+
if (operatorOptedOut && opts.sourceType === 'pipeline_step') {
|
|
4793
|
+
console.error(chalk.yellow('Warning: --no-auto-complete is ignored for pipeline_step sources; pipeline steps always auto-complete.'));
|
|
4794
|
+
}
|
|
4795
|
+
const forwardSuppress = operatorOptedOut && opts.sourceType !== 'pipeline_step';
|
|
4735
4796
|
// Resolve agent name to member ID if not already a UUID
|
|
4736
4797
|
let agentMemberId = opts.agent;
|
|
4737
4798
|
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-/.test(agentMemberId)) {
|
|
@@ -4768,8 +4829,24 @@ program
|
|
|
4768
4829
|
url: `https://github.com/formigio/${r}.git`,
|
|
4769
4830
|
branch: 'main',
|
|
4770
4831
|
})),
|
|
4771
|
-
cwd: '/workspace',
|
|
4772
4832
|
};
|
|
4833
|
+
// [F24 §3.2 / D8 / rul_workspace_clone_contract] cwd defaulting per
|
|
4834
|
+
// resolved repo count. Pre-F24 the CLI hardcoded cwd='/workspace',
|
|
4835
|
+
// which is ALWAYS empty inside the runner (clones land at
|
|
4836
|
+
// /home/agent/development/<repo>). BUG20's symptom ("'.git' missing")
|
|
4837
|
+
// was just the cwd misalignment — the clone itself was already
|
|
4838
|
+
// correct. Fix:
|
|
4839
|
+
// single repo → /home/agent/development/<repo> (align with clone)
|
|
4840
|
+
// multi repo → unset, let runner pick first repo via its existing
|
|
4841
|
+
// fallback at fazemos-agent-runner.ts:1075
|
|
4842
|
+
// zero repos → /workspace (preserve chat_session and no-repo cases)
|
|
4843
|
+
if (repoNames.length === 1) {
|
|
4844
|
+
context.cwd = `/home/agent/development/${repoNames[0]}`;
|
|
4845
|
+
}
|
|
4846
|
+
else if (repoNames.length === 0) {
|
|
4847
|
+
context.cwd = '/workspace';
|
|
4848
|
+
}
|
|
4849
|
+
// multi-repo: leave context.cwd unset — runner fallback chooses
|
|
4773
4850
|
// Resolve worksheet context for actions/commitments
|
|
4774
4851
|
if (opts.sourceType === 'action' || opts.sourceType === 'commitment') {
|
|
4775
4852
|
try {
|
|
@@ -4786,6 +4863,17 @@ program
|
|
|
4786
4863
|
context.worksheetName = detail.worksheet?.name;
|
|
4787
4864
|
context.worksheetPurpose = detail.worksheet?.purpose;
|
|
4788
4865
|
context.actionDescription = match.description || match.name;
|
|
4866
|
+
// [F24 §3.3 / D3 / rul_action_completion_semantics]
|
|
4867
|
+
// Propagate the action's target_value into context so the
|
|
4868
|
+
// agent's buildSelfReportingInstructions can branch:
|
|
4869
|
+
// target_value null|1 → binary auto-complete with -v 1
|
|
4870
|
+
// target_value > 1 → emit a "non-binary target" note,
|
|
4871
|
+
// NO auto-completion command
|
|
4872
|
+
// Only meaningful for source_type='action'; we set it only
|
|
4873
|
+
// here (the action-resolution branch).
|
|
4874
|
+
if (opts.sourceType === 'action') {
|
|
4875
|
+
context.actionTargetValue = match.target_value ?? null;
|
|
4876
|
+
}
|
|
4789
4877
|
// Include linked outcomes
|
|
4790
4878
|
if (detail.outcomes?.length) {
|
|
4791
4879
|
context.outcomes = detail.outcomes.map((o) => ({
|
|
@@ -4808,6 +4896,12 @@ program
|
|
|
4808
4896
|
}
|
|
4809
4897
|
if (opts.prompt)
|
|
4810
4898
|
context.prompt = opts.prompt;
|
|
4899
|
+
// [F24 §3.3 / D2] Forward --no-auto-complete intent. The CLI guard
|
|
4900
|
+
// above suppresses this for pipeline_step (forwardSuppress is false
|
|
4901
|
+
// in that case). Agent's buildSelfReportingInstructions reads
|
|
4902
|
+
// context.noAutoComplete; absent/false → default behavior.
|
|
4903
|
+
if (forwardSuppress)
|
|
4904
|
+
context.noAutoComplete = true;
|
|
4811
4905
|
const body = {
|
|
4812
4906
|
sourceType: opts.sourceType,
|
|
4813
4907
|
sourceId,
|