testdriverai 4.0.34 → 4.0.36
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/index.js +42 -4
- package/lib/init.js +1 -1
- package/lib/sdk.js +6 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -70,7 +70,8 @@ let getArgs = () => {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
if (!args[file]) {
|
|
73
|
-
|
|
73
|
+
if (!fs.existsSync(path.join(process.cwd(), 'testdriver'))) {
|
|
74
|
+
args[file] = 'testdriver/testdriver.yml'
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
// turn args[file] into local path
|
|
@@ -100,14 +101,49 @@ console.log('')
|
|
|
100
101
|
// individual run ID for this session
|
|
101
102
|
let runID = new Date().getTime();
|
|
102
103
|
|
|
104
|
+
function fileCompleter(line) {
|
|
105
|
+
line = line.slice(5); // remove /run
|
|
106
|
+
const lastSepIndex = line.lastIndexOf(path.sep);
|
|
107
|
+
let dir;
|
|
108
|
+
let partial;
|
|
109
|
+
if (lastSepIndex === -1) {
|
|
110
|
+
dir = '.';
|
|
111
|
+
partial = line;
|
|
112
|
+
}
|
|
113
|
+
else{
|
|
114
|
+
dir = line.slice(0, lastSepIndex + 1);
|
|
115
|
+
partial = line.slice(lastSepIndex + 1);
|
|
116
|
+
}
|
|
117
|
+
try{
|
|
118
|
+
const dirPath = path.resolve(process.cwd(), dir);
|
|
119
|
+
|
|
120
|
+
let files = fs.readdirSync(dirPath);
|
|
121
|
+
files = files.map(file => {
|
|
122
|
+
const fullFilePath = path.join(dirPath, file);
|
|
123
|
+
const fileStats = fs.statSync(fullFilePath);
|
|
124
|
+
return file + (fileStats.isDirectory() ? path.sep : ''); // add path.sep for dir
|
|
125
|
+
});
|
|
126
|
+
const matches = files.filter(file => file.startsWith(partial));
|
|
127
|
+
|
|
128
|
+
return [matches.length ? matches : files, partial];
|
|
129
|
+
}
|
|
130
|
+
catch(err){
|
|
131
|
+
return [[], partial];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
103
135
|
function completer(line) {
|
|
104
136
|
let completions = '/summarize /save /run /quit /explore /assert /undo /manual'.split(' ')
|
|
105
|
-
|
|
137
|
+
if(line.startsWith('/run ')){
|
|
138
|
+
return fileCompleter(line);
|
|
139
|
+
}
|
|
140
|
+
else{
|
|
106
141
|
completions.concat(tasks)
|
|
107
142
|
|
|
108
143
|
var hits = completions.filter(function(c) { return c.indexOf(line) == 0 })
|
|
109
144
|
// show all completions if none found
|
|
110
|
-
|
|
145
|
+
return [hits.length ? hits : completions, line]
|
|
146
|
+
}
|
|
111
147
|
}
|
|
112
148
|
|
|
113
149
|
if (!fs.existsSync(commandHistoryFile)) {
|
|
@@ -422,7 +458,9 @@ const generate = async (type) => {
|
|
|
422
458
|
for (const testPrompt of testPrompts) {
|
|
423
459
|
// with the contents of the testPrompt
|
|
424
460
|
let fileName = sanitizeFilename(testPrompt.headings[0]).trim().replace(/ /g, '-').toLowerCase() + '.md';
|
|
425
|
-
let path1 = path.join(process.cwd(), 'testdriver', '
|
|
461
|
+
let path1 = path.join(process.cwd(), 'testdriver', 'generate', fileName);
|
|
462
|
+
// create generate directory if it doesn't exist
|
|
463
|
+
if (!fs.existsSync(path.join(process.cwd(), 'testdriver', 'generate'))) {
|
|
426
464
|
let contents = testPrompt.listsOrdered[0].map((item, index) => `${index + 1}. /explore ${item}`).join('\n');
|
|
427
465
|
fs.writeFileSync(path1, contents);
|
|
428
466
|
}
|
package/lib/init.js
CHANGED
|
@@ -137,7 +137,7 @@ module.exports = async () => {
|
|
|
137
137
|
fs.mkdirSync(testdriverFolder);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
const testdriverGenerateFolder = path.join(process.cwd(), 'testdriver', '
|
|
140
|
+
const testdriverGenerateFolder = path.join(process.cwd(), 'testdriver', 'generate');
|
|
141
141
|
if (!fs.existsSync(testdriverGenerateFolder)) {
|
|
142
142
|
fs.mkdirSync(testdriverGenerateFolder);
|
|
143
143
|
}
|
package/lib/sdk.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
// custom "sdk" for calling our API
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
let root = "https://replayable-api-production.herokuapp.com";
|
|
4
|
+
|
|
5
|
+
if (process.env['DEV']) {
|
|
6
|
+
root = "https://replayable-dev-ian-mac-m1-16.ngrok.io";
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
const chalk = require('chalk');
|
|
6
10
|
const axios = require('axios');
|
|
7
11
|
const session = require('./session')
|