@narrative-os/cli 0.1.1 ā 0.1.3
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/commands/config.d.ts +1 -1
- package/dist/commands/config.js +20 -3
- package/dist/commands/init.js +49 -11
- package/dist/index.js +4 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ interface Config {
|
|
|
3
3
|
apiKey: string;
|
|
4
4
|
model: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function configCommand(): Promise<void>;
|
|
6
|
+
export declare function configCommand(showOnly?: boolean): Promise<void>;
|
|
7
7
|
export declare function getConfig(): Config | null;
|
|
8
8
|
export declare function applyConfig(): void;
|
|
9
9
|
export {};
|
package/dist/commands/config.js
CHANGED
|
@@ -31,9 +31,26 @@ function saveConfig(config) {
|
|
|
31
31
|
(0, fs_1.mkdirSync)(CONFIG_DIR, { recursive: true });
|
|
32
32
|
(0, fs_1.writeFileSync)(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
33
33
|
}
|
|
34
|
-
async function configCommand() {
|
|
35
|
-
const { select, password } = await import('@inquirer/prompts');
|
|
34
|
+
async function configCommand(showOnly = false) {
|
|
36
35
|
const existing = loadConfig();
|
|
36
|
+
// Show current configuration
|
|
37
|
+
if (showOnly) {
|
|
38
|
+
if (!existing) {
|
|
39
|
+
console.log('ā No configuration found.');
|
|
40
|
+
console.log('Run: nos config to set up your LLM provider');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
console.log('\nš Current Configuration:');
|
|
44
|
+
console.log('========================');
|
|
45
|
+
console.log(`Provider: ${existing.provider}`);
|
|
46
|
+
console.log(`Model: ${existing.model}`);
|
|
47
|
+
console.log(`API Key: ${existing.apiKey ? 'ā
Set (' + '*'.repeat(Math.min(existing.apiKey.length - 4, 8)) + existing.apiKey.slice(-4) + ')' : 'ā Not set'}`);
|
|
48
|
+
console.log('');
|
|
49
|
+
console.log(`Config file: ${CONFIG_FILE}`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
// Interactive configuration
|
|
53
|
+
const { select, password } = await import('@inquirer/prompts');
|
|
37
54
|
const provider = await select({
|
|
38
55
|
message: 'Select LLM provider:',
|
|
39
56
|
choices: PROVIDERS.map(p => ({ name: p.name, value: p.value })),
|
|
@@ -51,7 +68,7 @@ async function configCommand() {
|
|
|
51
68
|
});
|
|
52
69
|
const config = { provider: provider, model, apiKey };
|
|
53
70
|
saveConfig(config);
|
|
54
|
-
console.log(`\
|
|
71
|
+
console.log(`\nā
Configuration saved for ${providerInfo.name}`);
|
|
55
72
|
console.log(`Model: ${model}`);
|
|
56
73
|
}
|
|
57
74
|
function getConfig() {
|
package/dist/commands/init.js
CHANGED
|
@@ -3,22 +3,60 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.initCommand = initCommand;
|
|
4
4
|
const engine_1 = require("@narrative-os/engine");
|
|
5
5
|
const store_js_1 = require("../config/store.js");
|
|
6
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
6
7
|
async function initCommand(options) {
|
|
7
|
-
console.log('Creating new story...\n');
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
8
|
+
console.log('š Creating new story...\n');
|
|
9
|
+
// Prompt for required fields if not provided via CLI
|
|
10
|
+
const title = options.title || await (0, prompts_1.input)({
|
|
11
|
+
message: 'Story title:',
|
|
12
|
+
validate: (value) => value.trim().length > 0 || 'Title is required'
|
|
13
|
+
});
|
|
14
|
+
const genre = options.genre || await (0, prompts_1.select)({
|
|
15
|
+
message: 'Genre:',
|
|
16
|
+
choices: [
|
|
17
|
+
{ name: 'Science Fiction', value: 'Science Fiction' },
|
|
18
|
+
{ name: 'Fantasy', value: 'Fantasy' },
|
|
19
|
+
{ name: 'Mystery', value: 'Mystery' },
|
|
20
|
+
{ name: 'Thriller', value: 'Thriller' },
|
|
21
|
+
{ name: 'Romance', value: 'Romance' },
|
|
22
|
+
{ name: 'Historical Fiction', value: 'Historical Fiction' },
|
|
23
|
+
{ name: 'Horror', value: 'Horror' },
|
|
24
|
+
{ name: 'Literary Fiction', value: 'Literary Fiction' },
|
|
25
|
+
{ name: 'Other', value: 'Other' }
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
const theme = options.theme || await (0, prompts_1.input)({
|
|
29
|
+
message: 'Theme (e.g., Redemption, Love, Betrayal):',
|
|
30
|
+
default: 'Redemption'
|
|
31
|
+
});
|
|
32
|
+
const setting = options.setting || await (0, prompts_1.input)({
|
|
33
|
+
message: 'Setting (time/place):',
|
|
34
|
+
default: 'Modern day'
|
|
35
|
+
});
|
|
36
|
+
const tone = options.tone || await (0, prompts_1.input)({
|
|
37
|
+
message: 'Tone (e.g., Dark, Lighthearted, Suspenseful):',
|
|
38
|
+
default: 'Dramatic'
|
|
39
|
+
});
|
|
40
|
+
const premise = options.premise || await (0, prompts_1.input)({
|
|
41
|
+
message: 'Brief premise/synopsis:',
|
|
42
|
+
validate: (value) => value.trim().length > 10 || 'Please provide a more detailed premise (at least 10 characters)'
|
|
43
|
+
});
|
|
44
|
+
const targetChapters = options.chapters
|
|
45
|
+
? parseInt(options.chapters)
|
|
46
|
+
: await (0, prompts_1.number)({
|
|
47
|
+
message: 'Target number of chapters:',
|
|
48
|
+
default: 5,
|
|
49
|
+
min: 1,
|
|
50
|
+
max: 50
|
|
51
|
+
}) || 5;
|
|
15
52
|
let bible = (0, engine_1.createStoryBible)(title, theme, genre, setting, tone, premise, targetChapters);
|
|
16
|
-
|
|
17
|
-
bible = (0, engine_1.addCharacter)(bible, '
|
|
53
|
+
// Add a placeholder protagonist (user can add more characters later)
|
|
54
|
+
bible = (0, engine_1.addCharacter)(bible, 'Protagonist', 'protagonist', ['brave', 'determined'], ['achieve their goal']);
|
|
18
55
|
const state = (0, engine_1.createStoryState)(bible.id, targetChapters);
|
|
19
56
|
(0, store_js_1.saveStory)(bible, state, []);
|
|
20
|
-
console.log(`\nā
Story created: ${title}`);
|
|
57
|
+
console.log(`\nā
Story created: "${title}"`);
|
|
21
58
|
console.log(` ID: ${bible.id}`);
|
|
59
|
+
console.log(` Genre: ${genre}`);
|
|
22
60
|
console.log(` Target chapters: ${targetChapters}`);
|
|
23
61
|
console.log(`\nš” Next steps:`);
|
|
24
62
|
console.log(` ⢠Generate Chapter 1: nos generate ${bible.id}`);
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,10 @@ if (process.argv.length <= 2) {
|
|
|
29
29
|
program
|
|
30
30
|
.command('config')
|
|
31
31
|
.description('Configure LLM provider and API key')
|
|
32
|
-
.
|
|
32
|
+
.option('-s, --show', 'Show current configuration')
|
|
33
|
+
.action((options) => {
|
|
34
|
+
(0, config_js_1.configCommand)(options.show);
|
|
35
|
+
});
|
|
33
36
|
// Story Management
|
|
34
37
|
program
|
|
35
38
|
.command('init')
|