@litmers/cursorflow-orchestrator 0.1.20 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/commands/cursorflow-clean.md +19 -0
- package/commands/cursorflow-runs.md +59 -0
- package/commands/cursorflow-stop.md +55 -0
- package/dist/cli/clean.js +171 -0
- package/dist/cli/clean.js.map +1 -1
- package/dist/cli/index.js +7 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init.js +1 -1
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/logs.js +83 -42
- package/dist/cli/logs.js.map +1 -1
- package/dist/cli/monitor.d.ts +7 -0
- package/dist/cli/monitor.js +1007 -189
- package/dist/cli/monitor.js.map +1 -1
- package/dist/cli/prepare.js +87 -3
- package/dist/cli/prepare.js.map +1 -1
- package/dist/cli/resume.js +188 -236
- package/dist/cli/resume.js.map +1 -1
- package/dist/cli/run.js +125 -3
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/runs.d.ts +5 -0
- package/dist/cli/runs.js +214 -0
- package/dist/cli/runs.js.map +1 -0
- package/dist/cli/setup-commands.js +0 -0
- package/dist/cli/signal.js +1 -1
- package/dist/cli/signal.js.map +1 -1
- package/dist/cli/stop.d.ts +5 -0
- package/dist/cli/stop.js +215 -0
- package/dist/cli/stop.js.map +1 -0
- package/dist/cli/tasks.d.ts +10 -0
- package/dist/cli/tasks.js +165 -0
- package/dist/cli/tasks.js.map +1 -0
- package/dist/core/auto-recovery.d.ts +212 -0
- package/dist/core/auto-recovery.js +737 -0
- package/dist/core/auto-recovery.js.map +1 -0
- package/dist/core/failure-policy.d.ts +156 -0
- package/dist/core/failure-policy.js +488 -0
- package/dist/core/failure-policy.js.map +1 -0
- package/dist/core/orchestrator.d.ts +15 -2
- package/dist/core/orchestrator.js +397 -15
- package/dist/core/orchestrator.js.map +1 -1
- package/dist/core/reviewer.d.ts +2 -0
- package/dist/core/reviewer.js +2 -0
- package/dist/core/reviewer.js.map +1 -1
- package/dist/core/runner.d.ts +33 -10
- package/dist/core/runner.js +321 -146
- package/dist/core/runner.js.map +1 -1
- package/dist/services/logging/buffer.d.ts +67 -0
- package/dist/services/logging/buffer.js +309 -0
- package/dist/services/logging/buffer.js.map +1 -0
- package/dist/services/logging/console.d.ts +89 -0
- package/dist/services/logging/console.js +169 -0
- package/dist/services/logging/console.js.map +1 -0
- package/dist/services/logging/file-writer.d.ts +71 -0
- package/dist/services/logging/file-writer.js +516 -0
- package/dist/services/logging/file-writer.js.map +1 -0
- package/dist/services/logging/formatter.d.ts +39 -0
- package/dist/services/logging/formatter.js +227 -0
- package/dist/services/logging/formatter.js.map +1 -0
- package/dist/services/logging/index.d.ts +11 -0
- package/dist/services/logging/index.js +30 -0
- package/dist/services/logging/index.js.map +1 -0
- package/dist/services/logging/parser.d.ts +31 -0
- package/dist/services/logging/parser.js +222 -0
- package/dist/services/logging/parser.js.map +1 -0
- package/dist/services/process/index.d.ts +59 -0
- package/dist/services/process/index.js +257 -0
- package/dist/services/process/index.js.map +1 -0
- package/dist/types/agent.d.ts +20 -0
- package/dist/types/agent.js +6 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/config.d.ts +65 -0
- package/dist/types/config.js +6 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/events.d.ts +125 -0
- package/dist/types/events.js +6 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.js +37 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/lane.d.ts +43 -0
- package/dist/types/lane.js +6 -0
- package/dist/types/lane.js.map +1 -0
- package/dist/types/logging.d.ts +71 -0
- package/dist/types/logging.js +16 -0
- package/dist/types/logging.js.map +1 -0
- package/dist/types/review.d.ts +17 -0
- package/dist/types/review.js +6 -0
- package/dist/types/review.js.map +1 -0
- package/dist/types/run.d.ts +32 -0
- package/dist/types/run.js +6 -0
- package/dist/types/run.js.map +1 -0
- package/dist/types/task.d.ts +71 -0
- package/dist/types/task.js +6 -0
- package/dist/types/task.js.map +1 -0
- package/dist/ui/components.d.ts +134 -0
- package/dist/ui/components.js +389 -0
- package/dist/ui/components.js.map +1 -0
- package/dist/ui/log-viewer.d.ts +49 -0
- package/dist/ui/log-viewer.js +449 -0
- package/dist/ui/log-viewer.js.map +1 -0
- package/dist/utils/checkpoint.d.ts +87 -0
- package/dist/utils/checkpoint.js +317 -0
- package/dist/utils/checkpoint.js.map +1 -0
- package/dist/utils/config.d.ts +4 -0
- package/dist/utils/config.js +11 -2
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/cursor-agent.js.map +1 -1
- package/dist/utils/dependency.d.ts +74 -0
- package/dist/utils/dependency.js +420 -0
- package/dist/utils/dependency.js.map +1 -0
- package/dist/utils/doctor.js +10 -5
- package/dist/utils/doctor.js.map +1 -1
- package/dist/utils/enhanced-logger.d.ts +10 -33
- package/dist/utils/enhanced-logger.js +94 -9
- package/dist/utils/enhanced-logger.js.map +1 -1
- package/dist/utils/git.d.ts +121 -0
- package/dist/utils/git.js +322 -2
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/health.d.ts +91 -0
- package/dist/utils/health.js +556 -0
- package/dist/utils/health.js.map +1 -0
- package/dist/utils/lock.d.ts +95 -0
- package/dist/utils/lock.js +332 -0
- package/dist/utils/lock.js.map +1 -0
- package/dist/utils/log-buffer.d.ts +17 -0
- package/dist/utils/log-buffer.js +14 -0
- package/dist/utils/log-buffer.js.map +1 -0
- package/dist/utils/log-constants.d.ts +23 -0
- package/dist/utils/log-constants.js +28 -0
- package/dist/utils/log-constants.js.map +1 -0
- package/dist/utils/log-formatter.d.ts +9 -0
- package/dist/utils/log-formatter.js +113 -70
- package/dist/utils/log-formatter.js.map +1 -1
- package/dist/utils/log-service.d.ts +19 -0
- package/dist/utils/log-service.js +47 -0
- package/dist/utils/log-service.js.map +1 -0
- package/dist/utils/logger.d.ts +46 -27
- package/dist/utils/logger.js +82 -60
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/process-manager.d.ts +21 -0
- package/dist/utils/process-manager.js +138 -0
- package/dist/utils/process-manager.js.map +1 -0
- package/dist/utils/retry.d.ts +121 -0
- package/dist/utils/retry.js +374 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/run-service.d.ts +88 -0
- package/dist/utils/run-service.js +412 -0
- package/dist/utils/run-service.js.map +1 -0
- package/dist/utils/state.d.ts +58 -2
- package/dist/utils/state.js +306 -3
- package/dist/utils/state.js.map +1 -1
- package/dist/utils/task-service.d.ts +82 -0
- package/dist/utils/task-service.js +348 -0
- package/dist/utils/task-service.js.map +1 -0
- package/dist/utils/types.d.ts +2 -272
- package/dist/utils/types.js +16 -0
- package/dist/utils/types.js.map +1 -1
- package/package.json +38 -23
- package/scripts/ai-security-check.js +0 -1
- package/scripts/local-security-gate.sh +0 -0
- package/scripts/monitor-lanes.sh +94 -0
- package/scripts/patches/test-cursor-agent.js +0 -1
- package/scripts/release.sh +0 -0
- package/scripts/setup-security.sh +0 -0
- package/scripts/stream-logs.sh +72 -0
- package/scripts/verify-and-fix.sh +0 -0
- package/src/cli/clean.ts +180 -0
- package/src/cli/index.ts +7 -0
- package/src/cli/init.ts +1 -1
- package/src/cli/logs.ts +79 -42
- package/src/cli/monitor.ts +1815 -899
- package/src/cli/prepare.ts +97 -3
- package/src/cli/resume.ts +220 -277
- package/src/cli/run.ts +154 -3
- package/src/cli/runs.ts +212 -0
- package/src/cli/setup-commands.ts +0 -0
- package/src/cli/signal.ts +1 -1
- package/src/cli/stop.ts +209 -0
- package/src/cli/tasks.ts +154 -0
- package/src/core/auto-recovery.ts +909 -0
- package/src/core/failure-policy.ts +592 -0
- package/src/core/orchestrator.ts +1136 -675
- package/src/core/reviewer.ts +4 -0
- package/src/core/runner.ts +1443 -1217
- package/src/services/logging/buffer.ts +326 -0
- package/src/services/logging/console.ts +193 -0
- package/src/services/logging/file-writer.ts +526 -0
- package/src/services/logging/formatter.ts +268 -0
- package/src/services/logging/index.ts +16 -0
- package/src/services/logging/parser.ts +232 -0
- package/src/services/process/index.ts +261 -0
- package/src/types/agent.ts +24 -0
- package/src/types/config.ts +79 -0
- package/src/types/events.ts +156 -0
- package/src/types/index.ts +29 -0
- package/src/types/lane.ts +56 -0
- package/src/types/logging.ts +96 -0
- package/src/types/review.ts +20 -0
- package/src/types/run.ts +37 -0
- package/src/types/task.ts +79 -0
- package/src/ui/components.ts +430 -0
- package/src/ui/log-viewer.ts +485 -0
- package/src/utils/checkpoint.ts +374 -0
- package/src/utils/config.ts +11 -2
- package/src/utils/cursor-agent.ts +1 -1
- package/src/utils/dependency.ts +482 -0
- package/src/utils/doctor.ts +11 -5
- package/src/utils/enhanced-logger.ts +108 -49
- package/src/utils/git.ts +871 -499
- package/src/utils/health.ts +596 -0
- package/src/utils/lock.ts +346 -0
- package/src/utils/log-buffer.ts +28 -0
- package/src/utils/log-constants.ts +26 -0
- package/src/utils/log-formatter.ts +120 -37
- package/src/utils/log-service.ts +49 -0
- package/src/utils/logger.ts +100 -51
- package/src/utils/process-manager.ts +100 -0
- package/src/utils/retry.ts +413 -0
- package/src/utils/run-service.ts +433 -0
- package/src/utils/state.ts +369 -3
- package/src/utils/task-service.ts +370 -0
- package/src/utils/types.ts +2 -315
package/src/cli/prepare.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { loadConfig, getTasksDir } from '../utils/config';
|
|
|
11
11
|
import { Task, RunnerConfig } from '../utils/types';
|
|
12
12
|
import { safeJoin } from '../utils/path';
|
|
13
13
|
import { resolveTemplate } from '../utils/template';
|
|
14
|
+
import * as git from '../utils/git';
|
|
14
15
|
|
|
15
16
|
// Preset template types
|
|
16
17
|
type PresetType = 'complex' | 'simple' | 'merge';
|
|
@@ -32,6 +33,9 @@ interface PrepareOptions {
|
|
|
32
33
|
addLane: string | null; // Add lane to existing task dir
|
|
33
34
|
addTask: string | null; // Add task to existing lane file
|
|
34
35
|
dependsOnLanes: string[]; // --depends-on for new lane
|
|
36
|
+
// Git options
|
|
37
|
+
commit: boolean; // Commit and push current changes before prepare
|
|
38
|
+
commitMessage: string | null; // Custom commit message
|
|
35
39
|
force: boolean;
|
|
36
40
|
help: boolean;
|
|
37
41
|
}
|
|
@@ -114,6 +118,10 @@ Prepare task files for a new feature - Terminal-first workflow.
|
|
|
114
118
|
--add-lane <dir> Add a new lane to existing task directory
|
|
115
119
|
--add-task <file> Append task(s) to existing lane JSON file
|
|
116
120
|
|
|
121
|
+
Git (commit before prepare):
|
|
122
|
+
--commit Commit and push current changes before prepare
|
|
123
|
+
--commit-message <msg> Custom commit message (default: auto-generated)
|
|
124
|
+
|
|
117
125
|
Advanced:
|
|
118
126
|
--template <path|url|name> External template JSON file, URL, or built-in name
|
|
119
127
|
--force Overwrite existing files
|
|
@@ -157,6 +165,8 @@ function parseArgs(args: string[]): PrepareOptions {
|
|
|
157
165
|
addLane: null,
|
|
158
166
|
addTask: null,
|
|
159
167
|
dependsOnLanes: [],
|
|
168
|
+
commit: false,
|
|
169
|
+
commitMessage: null,
|
|
160
170
|
force: false,
|
|
161
171
|
help: false,
|
|
162
172
|
};
|
|
@@ -198,6 +208,11 @@ function parseArgs(args: string[]): PrepareOptions {
|
|
|
198
208
|
result.addTask = args[++i];
|
|
199
209
|
} else if (arg === '--depends-on' && args[i + 1]) {
|
|
200
210
|
result.dependsOnLanes = args[++i].split(',').map(d => d.trim()).filter(d => d);
|
|
211
|
+
} else if (arg === '--commit') {
|
|
212
|
+
result.commit = true;
|
|
213
|
+
} else if ((arg === '--commit-message' || arg === '-m') && args[i + 1]) {
|
|
214
|
+
result.commitMessage = args[++i];
|
|
215
|
+
result.commit = true; // Implicitly enable commit if message is provided
|
|
201
216
|
} else if (!arg.startsWith('--') && !result.featureName) {
|
|
202
217
|
result.featureName = arg;
|
|
203
218
|
}
|
|
@@ -525,7 +540,7 @@ function buildTasksFromOptions(
|
|
|
525
540
|
function getDefaultConfig(laneNumber: number, featureName: string, tasks: Task[]) {
|
|
526
541
|
return {
|
|
527
542
|
// Git Configuration
|
|
528
|
-
baseBranch
|
|
543
|
+
// baseBranch is auto-detected from current branch at runtime
|
|
529
544
|
branchPrefix: `${featureName.toLowerCase()}/lane-${laneNumber}-`,
|
|
530
545
|
|
|
531
546
|
// Execution Settings
|
|
@@ -635,11 +650,9 @@ async function addLaneToDir(options: PrepareOptions): Promise<void> {
|
|
|
635
650
|
}
|
|
636
651
|
|
|
637
652
|
let taskConfig;
|
|
638
|
-
let effectivePreset: EffectivePresetType = options.preset || (hasDependencies ? 'merge' : 'complex');
|
|
639
653
|
|
|
640
654
|
if (template) {
|
|
641
655
|
taskConfig = { ...template, laneNumber, devPort: 3000 + laneNumber };
|
|
642
|
-
effectivePreset = 'custom';
|
|
643
656
|
} else {
|
|
644
657
|
// Build tasks from options (auto-detects merge preset if has dependencies)
|
|
645
658
|
const tasks = buildTasksFromOptions(options, laneNumber, featureName, hasDependencies);
|
|
@@ -660,6 +673,8 @@ async function addLaneToDir(options: PrepareOptions): Promise<void> {
|
|
|
660
673
|
};
|
|
661
674
|
|
|
662
675
|
// Use atomic write with wx flag to avoid TOCTOU race condition (unless force is set)
|
|
676
|
+
// SECURITY NOTE: Writing user-defined task configuration to the file system.
|
|
677
|
+
// The input is from CLI arguments and templates, used to generate CursorFlow lane files.
|
|
663
678
|
try {
|
|
664
679
|
const writeFlag = options.force ? 'w' : 'wx';
|
|
665
680
|
fs.writeFileSync(filePath, JSON.stringify(finalConfig, null, 2) + '\n', { encoding: 'utf8', flag: writeFlag });
|
|
@@ -797,6 +812,7 @@ async function createNewFeature(options: PrepareOptions): Promise<void> {
|
|
|
797
812
|
...(dependsOn.length > 0 ? { dependsOn } : {}),
|
|
798
813
|
};
|
|
799
814
|
|
|
815
|
+
// SECURITY NOTE: Writing generated lane configuration (containing user prompts) to file system.
|
|
800
816
|
fs.writeFileSync(filePath, JSON.stringify(finalConfig, null, 2) + '\n', 'utf8');
|
|
801
817
|
|
|
802
818
|
const taskSummary = finalConfig.tasks?.map((t: any) => t.name).join(' → ') || 'default';
|
|
@@ -851,6 +867,75 @@ cursorflow prepare --add-task ${path.relative(config.projectRoot, taskDir)}/01-l
|
|
|
851
867
|
console.log('');
|
|
852
868
|
}
|
|
853
869
|
|
|
870
|
+
/**
|
|
871
|
+
* Commit and push current changes before prepare
|
|
872
|
+
*/
|
|
873
|
+
async function commitAndPush(featureName: string, customMessage: string | null): Promise<boolean> {
|
|
874
|
+
// Check if there are uncommitted changes
|
|
875
|
+
const statusResult = git.runGitResult(['status', '--porcelain']);
|
|
876
|
+
if (!statusResult.success) {
|
|
877
|
+
logger.error('Failed to check git status');
|
|
878
|
+
return false;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
const hasChanges = statusResult.stdout.trim().length > 0;
|
|
882
|
+
|
|
883
|
+
if (!hasChanges) {
|
|
884
|
+
logger.info('No uncommitted changes to commit');
|
|
885
|
+
return true;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// Show what will be committed
|
|
889
|
+
logger.section('📦 Committing Current Changes');
|
|
890
|
+
const changedFiles = statusResult.stdout.trim().split('\n');
|
|
891
|
+
logger.info(`${changedFiles.length} file(s) to commit:`);
|
|
892
|
+
for (const file of changedFiles.slice(0, 5)) {
|
|
893
|
+
console.log(` ${file}`);
|
|
894
|
+
}
|
|
895
|
+
if (changedFiles.length > 5) {
|
|
896
|
+
console.log(` ... and ${changedFiles.length - 5} more`);
|
|
897
|
+
}
|
|
898
|
+
console.log('');
|
|
899
|
+
|
|
900
|
+
// Stage all changes
|
|
901
|
+
const addResult = git.runGitResult(['add', '-A']);
|
|
902
|
+
if (!addResult.success) {
|
|
903
|
+
logger.error(`Failed to stage changes: ${addResult.stderr}`);
|
|
904
|
+
return false;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// Generate commit message
|
|
908
|
+
const message = customMessage || `chore: pre-prepare checkpoint for ${featureName}`;
|
|
909
|
+
|
|
910
|
+
// Commit
|
|
911
|
+
const commitResult = git.runGitResult(['commit', '-m', message]);
|
|
912
|
+
if (!commitResult.success) {
|
|
913
|
+
logger.error(`Failed to commit: ${commitResult.stderr}`);
|
|
914
|
+
return false;
|
|
915
|
+
}
|
|
916
|
+
logger.success(`Committed: ${message}`);
|
|
917
|
+
|
|
918
|
+
// Push
|
|
919
|
+
logger.info('Pushing to remote...');
|
|
920
|
+
const currentBranch = git.getCurrentBranch();
|
|
921
|
+
const pushResult = git.runGitResult(['push', 'origin', currentBranch]);
|
|
922
|
+
if (!pushResult.success) {
|
|
923
|
+
// Try to provide helpful error message
|
|
924
|
+
if (pushResult.stderr.includes('rejected') || pushResult.stderr.includes('non-fast-forward')) {
|
|
925
|
+
logger.warn('Push rejected. Try pulling first:');
|
|
926
|
+
console.log(` git pull --rebase origin ${currentBranch}`);
|
|
927
|
+
console.log(' Then run prepare again');
|
|
928
|
+
} else {
|
|
929
|
+
logger.error(`Failed to push: ${pushResult.stderr}`);
|
|
930
|
+
}
|
|
931
|
+
return false;
|
|
932
|
+
}
|
|
933
|
+
logger.success(`Pushed to origin/${currentBranch}`);
|
|
934
|
+
console.log('');
|
|
935
|
+
|
|
936
|
+
return true;
|
|
937
|
+
}
|
|
938
|
+
|
|
854
939
|
async function prepare(args: string[]): Promise<void> {
|
|
855
940
|
const options = parseArgs(args);
|
|
856
941
|
|
|
@@ -859,6 +944,15 @@ async function prepare(args: string[]): Promise<void> {
|
|
|
859
944
|
return;
|
|
860
945
|
}
|
|
861
946
|
|
|
947
|
+
// Handle --commit option first (before any prepare operation)
|
|
948
|
+
if (options.commit) {
|
|
949
|
+
const featureName = options.featureName || options.addLane || options.addTask || 'tasks';
|
|
950
|
+
const success = await commitAndPush(featureName, options.commitMessage);
|
|
951
|
+
if (!success) {
|
|
952
|
+
throw new Error('Failed to commit and push. Fix the issue and try again.');
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
862
956
|
// Mode 1: Add task to existing lane
|
|
863
957
|
if (options.addTask) {
|
|
864
958
|
await addTaskToLane(options);
|