@bicorne/task-flow 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +337 -145
- package/SKILL.md +9 -5
- package/assets/.harnessrc +0 -1
- package/dist/commands/analyze.js +160 -318
- package/dist/commands/archive.js +44 -48
- package/dist/commands/design.js +225 -400
- package/dist/commands/extract.js +174 -303
- package/dist/commands/init.js +103 -148
- package/dist/commands/merge/index.js +184 -295
- package/dist/commands/merge/merger.js +112 -134
- package/dist/commands/merge/types.js +3 -5
- package/dist/commands/merge/validators.js +115 -132
- package/dist/commands/merge.js +46 -13
- package/dist/commands/start.js +155 -248
- package/dist/commands/status.js +68 -129
- package/dist/commands/sync.js +37 -53
- package/dist/commands/tasks-gen/doc-parser.js +148 -228
- package/dist/commands/tasks-gen/generators.js +104 -116
- package/dist/commands/tasks-gen/index.js +206 -314
- package/dist/commands/tasks-gen/parsers.js +131 -232
- package/dist/commands/tasks-gen/templates.js +9 -10
- package/dist/commands/tasks-gen/types.js +36 -14
- package/dist/commands/tasks-gen/validators.js +33 -49
- package/dist/commands/tasks.js +58 -20
- package/dist/commands/worktree.js +167 -249
- package/dist/hooks/check-prd-exists.js +45 -55
- package/dist/hooks/check-worktree-conflict.js +68 -101
- package/dist/hooks/hook-runner/executor.js +134 -126
- package/dist/hooks/hook-runner/index.js +181 -196
- package/dist/hooks/hook-runner/loader.js +74 -113
- package/dist/hooks/hook-runner/types.js +3 -5
- package/dist/hooks/hook-runner.js +94 -28
- package/dist/hooks/phase-complete-detector.js +125 -191
- package/dist/hooks/phase-gate-validator.js +315 -376
- package/dist/hooks/save-checkpoint.js +87 -130
- package/dist/hooks/start-mcp-servers.js +50 -65
- package/dist/hooks/stop-mcp-servers.js +40 -49
- package/dist/index.js +84 -153
- package/dist/lib/archive.js +126 -209
- package/dist/lib/config.d.ts +0 -2
- package/dist/lib/config.js +141 -230
- package/dist/lib/constants.js +155 -145
- package/dist/lib/interactive.js +98 -148
- package/dist/lib/mcp-client.js +197 -320
- package/dist/lib/state.js +142 -253
- package/dist/slash/executor.js +309 -233
- package/dist/slash/index.js +69 -43
- package/dist/slash/parser.js +84 -97
- package/dist/slash/registry.js +100 -88
- package/dist/spec/openspec-to-task/builders.js +96 -109
- package/dist/spec/openspec-to-task/index.js +112 -173
- package/dist/spec/openspec-to-task/parsers.js +148 -219
- package/dist/spec/openspec-to-task/types.js +3 -5
- package/dist/spec/sync-openspec-to-task.js +47 -19
- package/dist/spec/sync-task-to-openspec.js +241 -272
- package/dist/types/ai-context.js +3 -8
- package/package.json +9 -7
- package/references/CLI-TUTORIAL.md +4 -10
package/dist/lib/constants.js
CHANGED
|
@@ -1,85 +1,116 @@
|
|
|
1
|
+
function e(e) {
|
|
2
|
+
return I.includes(e);
|
|
3
|
+
}
|
|
1
4
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: !0
|
|
7
|
+
});
|
|
8
|
+
var E = exports, s = {
|
|
9
|
+
get AGENT_TYPES () {
|
|
10
|
+
return p;
|
|
11
|
+
},
|
|
12
|
+
get ALLOWED_COMMANDS () {
|
|
13
|
+
return I;
|
|
14
|
+
},
|
|
15
|
+
get DEFAULTS () {
|
|
16
|
+
return l;
|
|
17
|
+
},
|
|
18
|
+
get DEFAULT_MERGE_CONFIG () {
|
|
19
|
+
return i;
|
|
20
|
+
},
|
|
21
|
+
get DIR_NAMES () {
|
|
22
|
+
return O;
|
|
23
|
+
},
|
|
24
|
+
get ERROR_CODES () {
|
|
25
|
+
return d;
|
|
26
|
+
},
|
|
27
|
+
get EVENT_TYPES () {
|
|
28
|
+
return D;
|
|
29
|
+
},
|
|
30
|
+
get FILE_PATTERNS () {
|
|
31
|
+
return a;
|
|
32
|
+
},
|
|
33
|
+
get GATE_VALIDATIONS () {
|
|
34
|
+
return N;
|
|
35
|
+
},
|
|
36
|
+
get HOOK_NAMES () {
|
|
37
|
+
return R;
|
|
38
|
+
},
|
|
39
|
+
get MERGE_TYPE () {
|
|
40
|
+
return T;
|
|
41
|
+
},
|
|
42
|
+
get PHASE () {
|
|
43
|
+
return t;
|
|
44
|
+
},
|
|
45
|
+
get REVIEW_CONCLUSION () {
|
|
46
|
+
return _;
|
|
47
|
+
},
|
|
48
|
+
get SKILL_FORMAT () {
|
|
49
|
+
return P;
|
|
50
|
+
},
|
|
51
|
+
get STATE_FILES () {
|
|
52
|
+
return o;
|
|
53
|
+
},
|
|
54
|
+
get STATUS () {
|
|
55
|
+
return r;
|
|
56
|
+
},
|
|
57
|
+
get VALIDATED_STATUSES () {
|
|
58
|
+
return A;
|
|
59
|
+
},
|
|
60
|
+
get VALIDATION_ALIASES () {
|
|
61
|
+
return c;
|
|
62
|
+
},
|
|
63
|
+
get VALIDATION_STATUS () {
|
|
64
|
+
return n;
|
|
65
|
+
},
|
|
66
|
+
get isAllowedCommand () {
|
|
67
|
+
return e;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
for(var S in s)Object.defineProperty(E, S, {
|
|
71
|
+
enumerable: !0,
|
|
72
|
+
get: Object.getOwnPropertyDescriptor(s, S).get
|
|
73
|
+
});
|
|
74
|
+
let t = {
|
|
16
75
|
PLANNING: 'planning',
|
|
17
76
|
IMPLEMENTATION: 'implementation',
|
|
18
77
|
REVIEW: 'review',
|
|
19
|
-
MERGE: 'merge'
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Status values
|
|
23
|
-
*/
|
|
24
|
-
exports.STATUS = {
|
|
78
|
+
MERGE: 'merge'
|
|
79
|
+
}, r = {
|
|
25
80
|
PENDING: 'pending',
|
|
26
81
|
RUNNING: 'running',
|
|
27
82
|
COMPLETED: 'completed',
|
|
28
83
|
BLOCKED: 'blocked',
|
|
29
84
|
FAILED: 'failed',
|
|
30
85
|
SKIPPED: 'skipped',
|
|
31
|
-
ACTIVE: 'active'
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Review conclusions
|
|
35
|
-
*/
|
|
36
|
-
exports.REVIEW_CONCLUSION = {
|
|
86
|
+
ACTIVE: 'active'
|
|
87
|
+
}, _ = {
|
|
37
88
|
PASS: 'PASS',
|
|
38
89
|
NEEDS_WORK: 'NEEDS_WORK',
|
|
39
|
-
FAIL: 'FAIL'
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Validation status values
|
|
43
|
-
*/
|
|
44
|
-
exports.VALIDATION_STATUS = {
|
|
90
|
+
FAIL: 'FAIL'
|
|
91
|
+
}, n = {
|
|
45
92
|
PASS: 'pass',
|
|
46
93
|
PASSED: 'passed',
|
|
47
94
|
SUCCESS: 'success',
|
|
48
95
|
OK: 'ok',
|
|
49
96
|
TRUE: 'true',
|
|
50
97
|
FAIL: 'fail',
|
|
51
|
-
FAILED: 'failed'
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
exports.VALIDATION_STATUS.SUCCESS,
|
|
60
|
-
exports.VALIDATION_STATUS.OK,
|
|
61
|
-
exports.VALIDATION_STATUS.TRUE,
|
|
62
|
-
];
|
|
63
|
-
/**
|
|
64
|
-
* Merge strategy types
|
|
65
|
-
*/
|
|
66
|
-
exports.MERGE_TYPE = {
|
|
98
|
+
FAILED: 'failed'
|
|
99
|
+
}, A = [
|
|
100
|
+
n.PASS,
|
|
101
|
+
n.PASSED,
|
|
102
|
+
n.SUCCESS,
|
|
103
|
+
n.OK,
|
|
104
|
+
n.TRUE
|
|
105
|
+
], T = {
|
|
67
106
|
SQUASH: 'squash',
|
|
68
107
|
MERGE: 'merge',
|
|
69
|
-
REBASE: 'rebase'
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
type: exports.MERGE_TYPE.SQUASH,
|
|
76
|
-
deleteBranch: true,
|
|
77
|
-
deleteWorktree: true,
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Allowed commands for CLI execution (security whitelist)
|
|
81
|
-
*/
|
|
82
|
-
exports.ALLOWED_COMMANDS = [
|
|
108
|
+
REBASE: 'rebase'
|
|
109
|
+
}, i = {
|
|
110
|
+
type: T.SQUASH,
|
|
111
|
+
deleteBranch: !0,
|
|
112
|
+
deleteWorktree: !0
|
|
113
|
+
}, I = [
|
|
83
114
|
'git',
|
|
84
115
|
'node',
|
|
85
116
|
'pnpm',
|
|
@@ -92,20 +123,8 @@ exports.ALLOWED_COMMANDS = [
|
|
|
92
123
|
'vitest',
|
|
93
124
|
'mocha',
|
|
94
125
|
'tsx',
|
|
95
|
-
'ts-node'
|
|
96
|
-
]
|
|
97
|
-
/**
|
|
98
|
-
* Check if a command is allowed
|
|
99
|
-
* @param cmd - Command to check
|
|
100
|
-
* @returns True if command is allowed
|
|
101
|
-
*/
|
|
102
|
-
function isAllowedCommand(cmd) {
|
|
103
|
-
return exports.ALLOWED_COMMANDS.includes(cmd);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* File patterns
|
|
107
|
-
*/
|
|
108
|
-
exports.FILE_PATTERNS = {
|
|
126
|
+
'ts-node'
|
|
127
|
+
], a = {
|
|
109
128
|
TASK_JSON: /^.+\.json$/,
|
|
110
129
|
SNAPSHOT_JSON: /.+-impl\.json$/,
|
|
111
130
|
REVIEW_MD: /.+-review\.md$/,
|
|
@@ -113,12 +132,8 @@ exports.FILE_PATTERNS = {
|
|
|
113
132
|
DESIGN_MD: /^design\.md$/,
|
|
114
133
|
TASKS_MD: /^tasks\.md$/,
|
|
115
134
|
EXECUTION_JSON: /^execution\.json$/,
|
|
116
|
-
MANIFEST_JSON: /^manifest\.json
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Directory names
|
|
120
|
-
*/
|
|
121
|
-
exports.DIR_NAMES = {
|
|
135
|
+
MANIFEST_JSON: /^manifest\.json$/
|
|
136
|
+
}, O = {
|
|
122
137
|
HARNESS: '.harness',
|
|
123
138
|
SPEC: 'spec',
|
|
124
139
|
CHANGES: 'changes',
|
|
@@ -127,22 +142,14 @@ exports.DIR_NAMES = {
|
|
|
127
142
|
REPORTS: 'reports',
|
|
128
143
|
ARCHIVE: 'archive',
|
|
129
144
|
WORKTREES: '.worktrees',
|
|
130
|
-
SKILLS: 'skills'
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* State file names
|
|
134
|
-
*/
|
|
135
|
-
exports.STATE_FILES = {
|
|
145
|
+
SKILLS: 'skills'
|
|
146
|
+
}, o = {
|
|
136
147
|
STATE: 'state.json',
|
|
137
148
|
CONFIG: '.harnessrc',
|
|
138
149
|
HOOKS: 'hooks.json',
|
|
139
150
|
MCP: 'mcp.json',
|
|
140
|
-
SKILLS: 'skills.json'
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Hook names
|
|
144
|
-
*/
|
|
145
|
-
exports.HOOK_NAMES = {
|
|
151
|
+
SKILLS: 'skills.json'
|
|
152
|
+
}, R = {
|
|
146
153
|
PRE_DESIGN: 'pre-design',
|
|
147
154
|
POST_DESIGN: 'post-design',
|
|
148
155
|
PRE_TASKS: 'pre-tasks',
|
|
@@ -154,12 +161,8 @@ exports.HOOK_NAMES = {
|
|
|
154
161
|
PRE_REVIEW: 'pre-review',
|
|
155
162
|
POST_REVIEW: 'post-review',
|
|
156
163
|
PRE_MERGE: 'pre-merge',
|
|
157
|
-
POST_MERGE: 'post-merge'
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Gate validation names
|
|
161
|
-
*/
|
|
162
|
-
exports.GATE_VALIDATIONS = {
|
|
164
|
+
POST_MERGE: 'post-merge'
|
|
165
|
+
}, N = {
|
|
163
166
|
BUILD_PASSES: 'build-passes',
|
|
164
167
|
TESTS_PASS: 'tests-pass',
|
|
165
168
|
TYPECHECK_PASSES: 'typecheck-passes',
|
|
@@ -167,40 +170,55 @@ exports.GATE_VALIDATIONS = {
|
|
|
167
170
|
SECURITY_CHECK: 'security-check',
|
|
168
171
|
COVERAGE_GE_80: 'coverage-ge-80',
|
|
169
172
|
REVIEW_CONCLUSION: 'review-conclusion',
|
|
170
|
-
PLANNING_READY: 'planning-ready'
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
[
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
173
|
+
PLANNING_READY: 'planning-ready'
|
|
174
|
+
}, c = {
|
|
175
|
+
[N.BUILD_PASSES]: [
|
|
176
|
+
'build-passes',
|
|
177
|
+
'build-pass',
|
|
178
|
+
'build',
|
|
179
|
+
'build-success'
|
|
180
|
+
],
|
|
181
|
+
[N.TESTS_PASS]: [
|
|
182
|
+
'tests-pass',
|
|
183
|
+
'test-pass',
|
|
184
|
+
'tests',
|
|
185
|
+
'test',
|
|
186
|
+
'unit-tests-pass'
|
|
187
|
+
],
|
|
188
|
+
[N.TYPECHECK_PASSES]: [
|
|
189
|
+
'typecheck-passes',
|
|
190
|
+
'type-check',
|
|
191
|
+
'typecheck',
|
|
192
|
+
"typescript-pass"
|
|
193
|
+
],
|
|
194
|
+
[N.LINT_PASSES]: [
|
|
195
|
+
'lint-passes',
|
|
196
|
+
'lint-pass',
|
|
197
|
+
'lint'
|
|
198
|
+
],
|
|
199
|
+
[N.SECURITY_CHECK]: [
|
|
200
|
+
'security-check',
|
|
201
|
+
'security-scan',
|
|
202
|
+
'security-review'
|
|
203
|
+
],
|
|
204
|
+
[N.COVERAGE_GE_80]: [
|
|
205
|
+
'coverage-ge-80',
|
|
206
|
+
'coverage-threshold',
|
|
207
|
+
'coverage-passes'
|
|
208
|
+
],
|
|
209
|
+
[N.REVIEW_CONCLUSION]: [
|
|
210
|
+
'review-conclusion',
|
|
211
|
+
'conclusion'
|
|
212
|
+
]
|
|
213
|
+
}, p = {
|
|
188
214
|
CLAUDE_CODE: 'claude-code',
|
|
189
215
|
TRAE: 'trae',
|
|
190
|
-
QODER: 'qoder'
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Skill formats
|
|
194
|
-
*/
|
|
195
|
-
exports.SKILL_FORMAT = {
|
|
216
|
+
QODER: 'qoder'
|
|
217
|
+
}, P = {
|
|
196
218
|
COPY_SKILL_MD: 'copy-skill-md',
|
|
197
219
|
COPY_DIRECTORY: 'copy-directory',
|
|
198
|
-
SYMLINK: 'symlink'
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Event types for archiving
|
|
202
|
-
*/
|
|
203
|
-
exports.EVENT_TYPES = {
|
|
220
|
+
SYMLINK: 'symlink'
|
|
221
|
+
}, D = {
|
|
204
222
|
TASK_STARTED: 'task_started',
|
|
205
223
|
PHASE_STARTED: 'phase_started',
|
|
206
224
|
PHASE_COMPLETED: 'phase_completed',
|
|
@@ -208,12 +226,8 @@ exports.EVENT_TYPES = {
|
|
|
208
226
|
REVIEW_COMPLETED: 'review_completed',
|
|
209
227
|
TASK_MERGED: 'task_merged',
|
|
210
228
|
TASK_COMPLETED: 'task_completed',
|
|
211
|
-
GATE_BLOCKED: 'gate_blocked'
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Error codes
|
|
215
|
-
*/
|
|
216
|
-
exports.ERROR_CODES = {
|
|
229
|
+
GATE_BLOCKED: 'gate_blocked'
|
|
230
|
+
}, d = {
|
|
217
231
|
MISSING_CHANGE: 'missing-change',
|
|
218
232
|
INVALID_CHANGE: 'invalid-change',
|
|
219
233
|
MISSING_TASK_ID: 'missing-task-id',
|
|
@@ -234,14 +248,10 @@ exports.ERROR_CODES = {
|
|
|
234
248
|
DIRTY_WORKTREE: 'dirty-worktree',
|
|
235
249
|
CANCELLED: 'cancelled',
|
|
236
250
|
SYNC_FAILED: 'sync-failed',
|
|
237
|
-
UNKNOWN_ERROR: 'unknown-error'
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
*/
|
|
242
|
-
exports.DEFAULTS = {
|
|
243
|
-
TIMEOUT: 300000, // 5 minutes
|
|
244
|
-
FORCE_KILL_TIMEOUT: 5000, // 5 seconds
|
|
251
|
+
UNKNOWN_ERROR: 'unknown-error'
|
|
252
|
+
}, l = {
|
|
253
|
+
TIMEOUT: 300000,
|
|
254
|
+
FORCE_KILL_TIMEOUT: 5000,
|
|
245
255
|
MAX_HISTORY_ENTRIES: 100,
|
|
246
|
-
MAX_WORKTREES: 10
|
|
256
|
+
MAX_WORKTREES: 10
|
|
247
257
|
};
|
package/dist/lib/interactive.js
CHANGED
|
@@ -1,166 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
-
var ownKeys = function(o) {
|
|
24
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
-
var ar = [];
|
|
26
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
-
return ar;
|
|
28
|
-
};
|
|
29
|
-
return ownKeys(o);
|
|
30
|
-
};
|
|
31
|
-
return function (mod) {
|
|
32
|
-
if (mod && mod.__esModule) return mod;
|
|
33
|
-
var result = {};
|
|
34
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
-
__setModuleDefault(result, mod);
|
|
36
|
-
return result;
|
|
37
|
-
};
|
|
38
|
-
})();
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.confirm = confirm;
|
|
41
|
-
exports.select = select;
|
|
42
|
-
exports.input = input;
|
|
43
|
-
exports.confirmOrExit = confirmOrExit;
|
|
44
|
-
exports.printPreview = printPreview;
|
|
45
|
-
const readline = __importStar(require("readline"));
|
|
46
|
-
function confirm(options) {
|
|
47
|
-
const rl = readline.createInterface({
|
|
1
|
+
function e(t) {
|
|
2
|
+
return "function" != typeof WeakMap ? null : (e = function(e) {
|
|
3
|
+
return new WeakMap();
|
|
4
|
+
})(t);
|
|
5
|
+
}
|
|
6
|
+
function t(e) {
|
|
7
|
+
let t = l.createInterface({
|
|
48
8
|
input: process.stdin,
|
|
49
|
-
output: process.stdout
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
resolve(options.defaultYes !== false);
|
|
59
|
-
}
|
|
60
|
-
else if (input === 'y' || input === 'yes') {
|
|
61
|
-
resolve(true);
|
|
62
|
-
}
|
|
63
|
-
else if (input === 'n' || input === 'no') {
|
|
64
|
-
resolve(false);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
resolve(options.defaultYes !== false);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
rl.on('error', () => {
|
|
71
|
-
rl.close();
|
|
72
|
-
resolve(options.defaultYes !== false);
|
|
9
|
+
output: process.stdout
|
|
10
|
+
}), r = !1 !== e.defaultYes ? '[Y/n]' : '[y/N]', o = `${e.message} ${r}: `;
|
|
11
|
+
return new Promise((r)=>{
|
|
12
|
+
t.question(o, (o)=>{
|
|
13
|
+
t.close();
|
|
14
|
+
let n = o.trim().toLowerCase();
|
|
15
|
+
'' === n ? r(!1 !== e.defaultYes) : 'y' === n || 'yes' === n ? r(!0) : 'n' === n || 'no' === n ? r(!1) : r(!1 !== e.defaultYes);
|
|
16
|
+
}), t.on('error', ()=>{
|
|
17
|
+
t.close(), r(!1 !== e.defaultYes);
|
|
73
18
|
});
|
|
74
19
|
});
|
|
75
20
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
21
|
+
function r(e) {
|
|
22
|
+
let t = l.createInterface({
|
|
78
23
|
input: process.stdin,
|
|
79
|
-
output: process.stdout
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
rl.close();
|
|
91
|
-
const input = answer.trim();
|
|
92
|
-
if (input === '' && options.defaultIndex !== undefined) {
|
|
93
|
-
resolve(options.choices[options.defaultIndex] || options.choices[0] || '');
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
const index = parseInt(input, 10) - 1;
|
|
97
|
-
if (index >= 0 && index < options.choices.length) {
|
|
98
|
-
resolve(options.choices[index] || options.choices[0] || '');
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
resolve(options.choices[0] || '');
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
rl.on('error', () => {
|
|
105
|
-
rl.close();
|
|
106
|
-
resolve(options.choices[0] || '');
|
|
24
|
+
output: process.stdout
|
|
25
|
+
}), r = e.choices.map((e, t)=>` ${t + 1}. ${e}`).join('\n'), o = void 0 !== e.defaultIndex ? ` (default: ${e.defaultIndex + 1})` : '', n = `${e.message}${o}\n${r}\nSelect: `;
|
|
26
|
+
return new Promise((r)=>{
|
|
27
|
+
t.question(n, (o)=>{
|
|
28
|
+
t.close();
|
|
29
|
+
let n = o.trim();
|
|
30
|
+
if ('' === n && void 0 !== e.defaultIndex) return void r(e.choices[e.defaultIndex] || e.choices[0] || '');
|
|
31
|
+
let s = parseInt(n, 10) - 1;
|
|
32
|
+
s >= 0 && s < e.choices.length ? r(e.choices[s] || e.choices[0] || '') : r(e.choices[0] || '');
|
|
33
|
+
}), t.on('error', ()=>{
|
|
34
|
+
t.close(), r(e.choices[0] || '');
|
|
107
35
|
});
|
|
108
36
|
});
|
|
109
37
|
}
|
|
110
|
-
function
|
|
111
|
-
|
|
38
|
+
function o(e) {
|
|
39
|
+
let t = l.createInterface({
|
|
112
40
|
input: process.stdin,
|
|
113
|
-
output: process.stdout
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (result === true) {
|
|
124
|
-
rl.close();
|
|
125
|
-
resolve(value);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
const errorMsg = typeof result === 'string' ? result : 'Invalid input';
|
|
129
|
-
console.log(` Error: ${errorMsg}`);
|
|
130
|
-
ask();
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
rl.close();
|
|
135
|
-
resolve(value);
|
|
136
|
-
}
|
|
41
|
+
output: process.stdout
|
|
42
|
+
}), r = e.default ? ` (default: ${e.default})` : '', o = `${e.message}${r}: `;
|
|
43
|
+
return new Promise((r)=>{
|
|
44
|
+
let n = ()=>{
|
|
45
|
+
t.question(o, (o)=>{
|
|
46
|
+
let s = o.trim() || e.default || '';
|
|
47
|
+
if (e.validator) {
|
|
48
|
+
let o = e.validator(s);
|
|
49
|
+
!0 === o ? (t.close(), r(s)) : (console.log(` Error: ${'string' == typeof o ? o : 'Invalid input'}`), n());
|
|
50
|
+
} else t.close(), r(s);
|
|
137
51
|
});
|
|
138
52
|
};
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
rl.close();
|
|
142
|
-
resolve(options.default || '');
|
|
53
|
+
n(), t.on('error', ()=>{
|
|
54
|
+
t.close(), r(e.default || '');
|
|
143
55
|
});
|
|
144
56
|
});
|
|
145
57
|
}
|
|
146
|
-
async function
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
58
|
+
async function n(e, r = !1) {
|
|
59
|
+
await t({
|
|
60
|
+
message: e,
|
|
61
|
+
defaultYes: r
|
|
62
|
+
}) || (console.log('\nOperation cancelled.'), process.exit(0));
|
|
152
63
|
}
|
|
153
|
-
function
|
|
154
|
-
console.log(`\n${
|
|
155
|
-
for (const [key, value] of Object.entries(items)) {
|
|
156
|
-
console.log(` ${key}: ${value}`);
|
|
157
|
-
}
|
|
64
|
+
function s(e, t) {
|
|
65
|
+
for (let [r, o] of (console.log(`\n${e}:`), Object.entries(t)))console.log(` ${r}: ${o}`);
|
|
158
66
|
console.log('');
|
|
159
67
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
68
|
+
"use strict";
|
|
69
|
+
Object.defineProperty(exports, "__esModule", {
|
|
70
|
+
value: !0
|
|
71
|
+
});
|
|
72
|
+
var c = exports, i = {
|
|
73
|
+
get confirm () {
|
|
74
|
+
return t;
|
|
75
|
+
},
|
|
76
|
+
get confirmOrExit () {
|
|
77
|
+
return n;
|
|
78
|
+
},
|
|
79
|
+
get default () {
|
|
80
|
+
return a;
|
|
81
|
+
},
|
|
82
|
+
get input () {
|
|
83
|
+
return o;
|
|
84
|
+
},
|
|
85
|
+
get printPreview () {
|
|
86
|
+
return s;
|
|
87
|
+
},
|
|
88
|
+
get select () {
|
|
89
|
+
return r;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
for(var u in i)Object.defineProperty(c, u, {
|
|
93
|
+
enumerable: !0,
|
|
94
|
+
get: Object.getOwnPropertyDescriptor(i, u).get
|
|
95
|
+
});
|
|
96
|
+
let l = /*#__PURE__*/ function(t) {
|
|
97
|
+
var r, o, n;
|
|
98
|
+
if (t && t.__esModule) return t;
|
|
99
|
+
if (null === t || "object" != typeof t && "function" != typeof t) return {
|
|
100
|
+
default: t
|
|
101
|
+
};
|
|
102
|
+
if ((r = e(void 0)) && r.has(t)) return r.get(t);
|
|
103
|
+
for(var s in o = {
|
|
104
|
+
__proto__: null
|
|
105
|
+
}, n = Object.defineProperty && Object.getOwnPropertyDescriptor, t)if ("default" !== s && Object.prototype.hasOwnProperty.call(t, s)) {
|
|
106
|
+
var c = n ? Object.getOwnPropertyDescriptor(t, s) : null;
|
|
107
|
+
c && (c.get || c.set) ? Object.defineProperty(o, s, c) : o[s] = t[s];
|
|
108
|
+
}
|
|
109
|
+
return o.default = t, r && r.set(t, o), o;
|
|
110
|
+
}(require("readline")), a = {
|
|
111
|
+
confirm: t,
|
|
112
|
+
select: r,
|
|
113
|
+
input: o,
|
|
114
|
+
confirmOrExit: n,
|
|
115
|
+
printPreview: s
|
|
166
116
|
};
|