dayloom 0.1.0-beta.0 → 0.1.0-beta.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/dist/daily/dialogue-loop.js +19 -27
- package/dist/init/interview-loop.js +65 -11
- package/dist/play/event-loop.js +22 -3
- package/dist/revise/dialogue-loop.js +20 -7
- package/dist/session-commands/format.js +14 -0
- package/dist/session-commands/index.js +9 -0
- package/dist/session-commands/parse.js +16 -0
- package/dist/session-commands/types.js +2 -0
- package/package.json +2 -2
- package/prompts/init-interviewer.system.md +1 -0
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dailyInteractive = dailyInteractive;
|
|
4
4
|
const filtered_stream_output_1 = require("../shared/filtered-stream-output");
|
|
5
|
+
const session_commands_1 = require("../session-commands");
|
|
5
6
|
const loading_1 = require("../utils/loading");
|
|
6
7
|
const constants_1 = require("./constants");
|
|
7
8
|
const apply_plan_1 = require("./apply-plan");
|
|
8
9
|
const finalize_1 = require("./finalize");
|
|
9
10
|
const guard_1 = require("./guard");
|
|
10
|
-
const intent_router_1 = require("./intent-router");
|
|
11
11
|
const mcp_gateway_1 = require("./mcp-gateway");
|
|
12
12
|
const mcp_tools_1 = require("./mcp-tools");
|
|
13
13
|
const parse_assistant_1 = require("./parse-assistant");
|
|
@@ -17,6 +17,13 @@ const promptpile_loop_1 = require("./promptpile-loop");
|
|
|
17
17
|
const read_user_input_1 = require("./read-user-input");
|
|
18
18
|
const session_1 = require("./session");
|
|
19
19
|
const validate_plan_1 = require("./validate-plan");
|
|
20
|
+
const DAILY_COMMANDS = [
|
|
21
|
+
{ name: 'help', summary: 'Show daily commands.' },
|
|
22
|
+
{ name: 'status', aliases: ['pending'], summary: 'Show the current daily draft.' },
|
|
23
|
+
{ name: 'save', aliases: ['start'], summary: 'Finalize and apply the daily plan.' },
|
|
24
|
+
{ name: 'cancel', summary: 'Discard the current daily draft.' },
|
|
25
|
+
{ name: 'exit', summary: 'Exit and preserve the daily session.' },
|
|
26
|
+
];
|
|
20
27
|
async function dailyInteractive(dir, options = {}) {
|
|
21
28
|
if (!process.env.DEEPSEEK_API_KEY?.trim())
|
|
22
29
|
throw new Error('DEEPSEEK_API_KEY is not set. Interactive daily requires an API key.');
|
|
@@ -40,7 +47,7 @@ async function dailyInteractive(dir, options = {}) {
|
|
|
40
47
|
});
|
|
41
48
|
if (!gateway)
|
|
42
49
|
throw new Error('Failed to initialize readonly gateway');
|
|
43
|
-
process.stdout.write(`\n--- Daily planning session ---\n\n${constants_1.OPENING_ASSISTANT}\n`);
|
|
50
|
+
process.stdout.write(`\n--- Daily planning session ---\n\n${(0, session_commands_1.formatAvailableCommands)(DAILY_COMMANDS)}\n${constants_1.OPENING_ASSISTANT}\n`);
|
|
44
51
|
while (true) {
|
|
45
52
|
const input = await (0, read_user_input_1.readDailyUserInput)();
|
|
46
53
|
if (input === undefined) {
|
|
@@ -48,35 +55,25 @@ async function dailyInteractive(dir, options = {}) {
|
|
|
48
55
|
process.stdout.write(`Daily draft saved in session: ${session.root}\n`);
|
|
49
56
|
return;
|
|
50
57
|
}
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
53
|
-
|
|
58
|
+
const command = (0, session_commands_1.parseSessionCommand)(input, DAILY_COMMANDS);
|
|
59
|
+
if (command.kind === 'unknown') {
|
|
60
|
+
process.stdout.write((0, session_commands_1.formatUnknownCommand)(command.raw));
|
|
54
61
|
continue;
|
|
55
62
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
else {
|
|
60
|
-
let intent = (0, intent_router_1.fallbackDailyIntent)('Intent router was not called');
|
|
61
|
-
try {
|
|
62
|
-
intent = await (0, loading_1.withLoading)('正在识别操作...', () => (0, intent_router_1.routeDailyIntent)(input, (0, session_1.readDraft)(session), (0, session_1.getLatestAssistantText)(session.messagesDir), gateway.baseUrl, gateway.token, maxToolRounds, false));
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
process.stderr.write(`Warning: daily intent router failed; treating input as a planning message: ${error instanceof Error ? error.message : error}\n`);
|
|
66
|
-
intent = (0, intent_router_1.fallbackDailyIntent)('Router failure');
|
|
67
|
-
}
|
|
68
|
-
action = (0, intent_router_1.effectiveDailyAction)(intent);
|
|
63
|
+
if (command.kind === 'command' && command.name === 'help') {
|
|
64
|
+
process.stdout.write((0, session_commands_1.formatCommandHelp)(DAILY_COMMANDS));
|
|
65
|
+
continue;
|
|
69
66
|
}
|
|
70
|
-
if (
|
|
67
|
+
if (command.kind === 'command' && command.name === 'status') {
|
|
71
68
|
process.stdout.write(`${JSON.stringify((0, session_1.readDraft)(session), null, 2)}\n`);
|
|
72
69
|
continue;
|
|
73
70
|
}
|
|
74
|
-
if (
|
|
71
|
+
if (command.kind === 'command' && command.name === 'exit') {
|
|
75
72
|
preserveSession = true;
|
|
76
73
|
process.stdout.write(`Daily draft saved in session: ${session.root}\n`);
|
|
77
74
|
return;
|
|
78
75
|
}
|
|
79
|
-
if (
|
|
76
|
+
if (command.kind === 'command' && command.name === 'cancel') {
|
|
80
77
|
if (await (0, read_user_input_1.askYesNo)('Discard the current daily draft? (Y/N): ')) {
|
|
81
78
|
process.stdout.write('Daily planning cancelled.\n');
|
|
82
79
|
return;
|
|
@@ -84,9 +81,7 @@ async function dailyInteractive(dir, options = {}) {
|
|
|
84
81
|
process.stdout.write('Daily planning continues.\n');
|
|
85
82
|
continue;
|
|
86
83
|
}
|
|
87
|
-
if (
|
|
88
|
-
if (!explicit)
|
|
89
|
-
(0, session_1.appendUserMessage)(session.messagesDir, input);
|
|
84
|
+
if (command.kind === 'command' && command.name === 'save') {
|
|
90
85
|
const applied = await finalizeAndApplyPlan(worldRoot, day, lastCommittedDay, session, gateway.baseUrl, gateway.token, maxToolRounds, options);
|
|
91
86
|
if (applied)
|
|
92
87
|
return;
|
|
@@ -142,6 +137,3 @@ async function finalizeAndApplyPlan(worldRoot, day, lastCommittedDay, session, b
|
|
|
142
137
|
process.stdout.write('Applied daily plan.\n');
|
|
143
138
|
return true;
|
|
144
139
|
}
|
|
145
|
-
function printHelp() {
|
|
146
|
-
process.stdout.write('Use natural language to discuss, inspect, confirm, cancel, or save the plan. Commands remain available: /pending /start /cancel /exit\n');
|
|
147
|
-
}
|
|
@@ -7,19 +7,17 @@ const errors_1 = require("./errors");
|
|
|
7
7
|
const parse_assistant_1 = require("./parse-assistant");
|
|
8
8
|
const promptpile_run_1 = require("./promptpile-run");
|
|
9
9
|
const read_user_input_1 = require("./read-user-input");
|
|
10
|
+
const read_user_input_2 = require("../revise/read-user-input");
|
|
11
|
+
const session_commands_1 = require("../session-commands");
|
|
10
12
|
const session_1 = require("./session");
|
|
13
|
+
const INIT_COMMANDS = [
|
|
14
|
+
{ name: 'help', summary: 'Show init commands.' },
|
|
15
|
+
{ name: 'status', summary: 'Show likely missing World setup topics.' },
|
|
16
|
+
{ name: 'save', summary: 'Finalize and write the World save.' },
|
|
17
|
+
{ name: 'cancel', summary: 'Cancel initialization.' },
|
|
18
|
+
{ name: 'exit', summary: 'Exit initialization.' },
|
|
19
|
+
];
|
|
11
20
|
async function runInterviewRound(session, onDelta) {
|
|
12
|
-
let userText;
|
|
13
|
-
try {
|
|
14
|
-
userText = await (0, read_user_input_1.readUserInput)();
|
|
15
|
-
}
|
|
16
|
-
catch (err) {
|
|
17
|
-
if (err instanceof errors_1.InitCancelledError) {
|
|
18
|
-
throw new errors_1.InitCancelledError(err.message, session);
|
|
19
|
-
}
|
|
20
|
-
throw err;
|
|
21
|
-
}
|
|
22
|
-
(0, session_1.appendUserMessage)(session.messagesDir, userText);
|
|
23
21
|
const result = await (0, promptpile_run_1.runPromptpile)(session, [
|
|
24
22
|
'--config',
|
|
25
23
|
'promptpile.toml',
|
|
@@ -35,10 +33,60 @@ async function runInterviewLoop(maxRounds = constants_1.DEFAULT_MAX_INTERVIEW_RO
|
|
|
35
33
|
const session = (0, session_1.createSession)();
|
|
36
34
|
(0, session_1.writeOpeningAssistant)(session.messagesDir, constants_1.OPENING_ASSISTANT);
|
|
37
35
|
process.stdout.write('\n--- World building interview ---\n\n');
|
|
36
|
+
process.stdout.write((0, session_commands_1.formatAvailableCommands)(INIT_COMMANDS));
|
|
37
|
+
process.stdout.write('\n');
|
|
38
38
|
process.stdout.write(stripDisplay(constants_1.OPENING_ASSISTANT));
|
|
39
39
|
process.stdout.write('\n');
|
|
40
40
|
for (let round = 1; round <= maxRounds; round += 1) {
|
|
41
41
|
session.round = round;
|
|
42
|
+
let userText;
|
|
43
|
+
try {
|
|
44
|
+
userText = await (0, read_user_input_1.readUserInput)();
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
if (err instanceof errors_1.InitCancelledError) {
|
|
48
|
+
throw new errors_1.InitCancelledError(err.message, session);
|
|
49
|
+
}
|
|
50
|
+
throw err;
|
|
51
|
+
}
|
|
52
|
+
const command = (0, session_commands_1.parseSessionCommand)(userText, INIT_COMMANDS);
|
|
53
|
+
if (command.kind === 'unknown') {
|
|
54
|
+
process.stdout.write((0, session_commands_1.formatUnknownCommand)(command.raw));
|
|
55
|
+
round -= 1;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (command.kind === 'command') {
|
|
59
|
+
if (command.name === 'help') {
|
|
60
|
+
process.stdout.write((0, session_commands_1.formatCommandHelp)(INIT_COMMANDS));
|
|
61
|
+
round -= 1;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (command.name === 'status') {
|
|
65
|
+
printMissingTopics((0, session_1.buildTranscript)(session.messagesDir));
|
|
66
|
+
round -= 1;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (command.name === 'cancel') {
|
|
70
|
+
throw new errors_1.InitCancelledError('Initialization cancelled.', session);
|
|
71
|
+
}
|
|
72
|
+
if (command.name === 'exit') {
|
|
73
|
+
throw new errors_1.InitCancelledError('Initialization exited.', session);
|
|
74
|
+
}
|
|
75
|
+
if (command.name === 'save') {
|
|
76
|
+
const transcript = (0, session_1.buildTranscript)(session.messagesDir);
|
|
77
|
+
const missing = (0, checklist_1.getInterviewMissingFromTranscript)(transcript);
|
|
78
|
+
if (missing.length > 0) {
|
|
79
|
+
process.stdout.write(`Possible missing topics: ${missing.join(', ')}.\n`);
|
|
80
|
+
if (!await (0, read_user_input_2.askYesNo)('Continue saving anyway? (Y/N): ')) {
|
|
81
|
+
round -= 1;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
process.stdout.write('\nInterview complete. Finalizing world save...\n');
|
|
86
|
+
return { session, transcript };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
(0, session_1.appendUserMessage)(session.messagesDir, userText);
|
|
42
90
|
process.stdout.write('\n--- Assistant ---\n\n');
|
|
43
91
|
const displayStream = createInitDisplayStream();
|
|
44
92
|
const assistantText = await runInterviewRound(session, text => displayStream.push(text));
|
|
@@ -101,3 +149,9 @@ function createInitDisplayStream() {
|
|
|
101
149
|
}
|
|
102
150
|
};
|
|
103
151
|
}
|
|
152
|
+
function printMissingTopics(transcript) {
|
|
153
|
+
const missing = (0, checklist_1.getInterviewMissingFromTranscript)(transcript);
|
|
154
|
+
process.stdout.write(missing.length > 0
|
|
155
|
+
? `Likely missing topics: ${missing.join(', ')}\n`
|
|
156
|
+
: 'No likely missing topics.\n');
|
|
157
|
+
}
|
package/dist/play/event-loop.js
CHANGED
|
@@ -11,12 +11,19 @@ const mcp_gateway_1 = require("../daily/mcp-gateway");
|
|
|
11
11
|
const mcp_tools_1 = require("../daily/mcp-tools");
|
|
12
12
|
const read_user_input_1 = require("../daily/read-user-input");
|
|
13
13
|
const filtered_stream_output_1 = require("../shared/filtered-stream-output");
|
|
14
|
+
const session_commands_1 = require("../session-commands");
|
|
14
15
|
const ai_1 = require("./ai");
|
|
15
16
|
const player_context_1 = require("./player-context");
|
|
16
17
|
const parse_assistant_1 = require("./parse-assistant");
|
|
17
18
|
const state_1 = require("./state");
|
|
18
19
|
const validate_1 = require("./validate");
|
|
19
20
|
const loading_1 = require("../utils/loading");
|
|
21
|
+
const PLAY_COMMANDS = [
|
|
22
|
+
{ name: 'help', summary: 'Show play commands.' },
|
|
23
|
+
{ name: 'status', summary: 'Show the current event definition.' },
|
|
24
|
+
{ name: 'exit', summary: 'Exit play and keep progress in the World save.' },
|
|
25
|
+
{ name: 'end-day', summary: 'End the current day after this event.' },
|
|
26
|
+
];
|
|
20
27
|
async function runPlayLoop(worldRoot, day, options = {}) {
|
|
21
28
|
if (!process.env.DEEPSEEK_API_KEY?.trim())
|
|
22
29
|
throw new Error('DEEPSEEK_API_KEY is not set. Play requires an API key.');
|
|
@@ -108,18 +115,30 @@ async function dialogue(worldRoot, day, id, tools, base, token, maxTools, maxRou
|
|
|
108
115
|
process.stdout.write('\n--- ' + event.title + ' ---\n\n' + event.opening + '\n\n' + event.situation + '\n');
|
|
109
116
|
if (event.suggested_actions.length)
|
|
110
117
|
process.stdout.write(event.suggested_actions.map((x, i) => (i + 1) + '. ' + x).join('\n') + '\n');
|
|
118
|
+
process.stdout.write('\n' + (0, session_commands_1.formatAvailableCommands)(PLAY_COMMANDS));
|
|
111
119
|
while (true) {
|
|
112
120
|
const rounds = (transcript.match(/^## User$/gm) ?? []).length;
|
|
113
121
|
if (rounds >= maxRounds)
|
|
114
122
|
throw new Error('Event exceeded max dialogue rounds (' + maxRounds + ')');
|
|
115
123
|
const input = await (0, read_user_input_1.readDailyUserInput)();
|
|
116
|
-
if (input === undefined
|
|
124
|
+
if (input === undefined)
|
|
117
125
|
return true;
|
|
118
|
-
|
|
126
|
+
const command = (0, session_commands_1.parseSessionCommand)(input, PLAY_COMMANDS);
|
|
127
|
+
if (command.kind === 'unknown') {
|
|
128
|
+
process.stdout.write((0, session_commands_1.formatUnknownCommand)(command.raw));
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (command.kind === 'command' && command.name === 'help') {
|
|
132
|
+
process.stdout.write((0, session_commands_1.formatCommandHelp)(PLAY_COMMANDS));
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (command.kind === 'command' && command.name === 'exit')
|
|
136
|
+
return true;
|
|
137
|
+
if (command.kind === 'command' && command.name === 'status') {
|
|
119
138
|
process.stdout.write(fs_1.default.readFileSync(path_1.default.join(dir, 'event.json'), 'utf8'));
|
|
120
139
|
continue;
|
|
121
140
|
}
|
|
122
|
-
if (
|
|
141
|
+
if (command.kind === 'command' && command.name === 'end-day') {
|
|
123
142
|
const status = { status: 'resolved', situation: 'The player explicitly ended the day.', needs_user_action: false, resolution_summary: 'The player explicitly ended the current day.', end_day: true };
|
|
124
143
|
const machine = '```event-status\n' + JSON.stringify(status, null, 2) + '\n```';
|
|
125
144
|
transcript += '\n## User\n\n/end-day\n\n## Assistant\n\nThe day ends here.\n\n' + machine + '\n';
|
|
@@ -16,7 +16,15 @@ const session_1 = require("./session");
|
|
|
16
16
|
const project_payload_1 = require("./project-payload");
|
|
17
17
|
const validate_payload_1 = require("./validate-payload");
|
|
18
18
|
const filtered_stream_output_1 = require("../shared/filtered-stream-output");
|
|
19
|
+
const session_commands_1 = require("../session-commands");
|
|
19
20
|
const loading_1 = require("../utils/loading");
|
|
21
|
+
const REVISE_COMMANDS = [
|
|
22
|
+
{ name: 'help', summary: 'Show revise commands.' },
|
|
23
|
+
{ name: 'status', aliases: ['pending'], summary: 'Show the current pending revision draft.' },
|
|
24
|
+
{ name: 'save', aliases: ['apply'], summary: 'Finalize and apply the revision.' },
|
|
25
|
+
{ name: 'cancel', summary: 'Cancel the revision session.' },
|
|
26
|
+
{ name: 'exit', summary: 'Exit and preserve the revision session.' },
|
|
27
|
+
];
|
|
20
28
|
async function reviseWorldInteractive(dir, options = {}) {
|
|
21
29
|
if (!process.env.DEEPSEEK_API_KEY?.trim())
|
|
22
30
|
throw new Error('DEEPSEEK_API_KEY is not set. Interactive revise requires an API key.');
|
|
@@ -35,7 +43,7 @@ async function reviseWorldInteractive(dir, options = {}) {
|
|
|
35
43
|
});
|
|
36
44
|
if (!gateway)
|
|
37
45
|
throw new Error('Failed to initialize readonly gateway');
|
|
38
|
-
process.stdout.write(`\n--- World revision session ---\n\n${constants_1.OPENING_ASSISTANT}\n`);
|
|
46
|
+
process.stdout.write(`\n--- World revision session ---\n\n${(0, session_commands_1.formatAvailableCommands)(REVISE_COMMANDS)}\n${constants_1.OPENING_ASSISTANT}\n`);
|
|
39
47
|
while (true) {
|
|
40
48
|
const input = await (0, read_user_input_1.readReviseUserInput)();
|
|
41
49
|
if (input === undefined) {
|
|
@@ -43,24 +51,29 @@ async function reviseWorldInteractive(dir, options = {}) {
|
|
|
43
51
|
process.stdout.write(`Revision draft saved in session: ${session.root}\n`);
|
|
44
52
|
return;
|
|
45
53
|
}
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
const command = (0, session_commands_1.parseSessionCommand)(input, REVISE_COMMANDS);
|
|
55
|
+
if (command.kind === 'unknown') {
|
|
56
|
+
process.stdout.write((0, session_commands_1.formatUnknownCommand)(command.raw));
|
|
48
57
|
continue;
|
|
49
58
|
}
|
|
50
|
-
if (
|
|
59
|
+
if (command.kind === 'command' && command.name === 'help') {
|
|
60
|
+
process.stdout.write((0, session_commands_1.formatCommandHelp)(REVISE_COMMANDS));
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (command.kind === 'command' && command.name === 'status') {
|
|
51
64
|
process.stdout.write(`${JSON.stringify((0, session_1.readDraft)(session), null, 2)}\n`);
|
|
52
65
|
continue;
|
|
53
66
|
}
|
|
54
|
-
if (
|
|
67
|
+
if (command.kind === 'command' && command.name === 'cancel') {
|
|
55
68
|
process.stdout.write('Revision cancelled.\n');
|
|
56
69
|
return;
|
|
57
70
|
}
|
|
58
|
-
if (
|
|
71
|
+
if (command.kind === 'command' && command.name === 'exit') {
|
|
59
72
|
preserveSession = true;
|
|
60
73
|
process.stdout.write(`Revision draft saved in session: ${session.root}\n`);
|
|
61
74
|
return;
|
|
62
75
|
}
|
|
63
|
-
if (
|
|
76
|
+
if (command.kind === 'command' && command.name === 'save') {
|
|
64
77
|
const draft = (0, session_1.readDraft)(session);
|
|
65
78
|
if (!draft.pending_changes.length) {
|
|
66
79
|
process.stdout.write('No pending changes.\n');
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatAvailableCommands = formatAvailableCommands;
|
|
4
|
+
exports.formatCommandHelp = formatCommandHelp;
|
|
5
|
+
exports.formatUnknownCommand = formatUnknownCommand;
|
|
6
|
+
function formatAvailableCommands(specs, label = 'Available commands') {
|
|
7
|
+
return `${label}: ${specs.map(spec => `/${spec.name}`).join(' ')}\n`;
|
|
8
|
+
}
|
|
9
|
+
function formatCommandHelp(specs) {
|
|
10
|
+
return specs.map(spec => `/${spec.name} ${spec.summary}`).join('\n') + '\n';
|
|
11
|
+
}
|
|
12
|
+
function formatUnknownCommand(raw) {
|
|
13
|
+
return `Unknown command: ${raw}\nType /help to see commands available in this session.\n`;
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseSessionCommand = exports.formatUnknownCommand = exports.formatCommandHelp = exports.formatAvailableCommands = void 0;
|
|
4
|
+
var format_1 = require("./format");
|
|
5
|
+
Object.defineProperty(exports, "formatAvailableCommands", { enumerable: true, get: function () { return format_1.formatAvailableCommands; } });
|
|
6
|
+
Object.defineProperty(exports, "formatCommandHelp", { enumerable: true, get: function () { return format_1.formatCommandHelp; } });
|
|
7
|
+
Object.defineProperty(exports, "formatUnknownCommand", { enumerable: true, get: function () { return format_1.formatUnknownCommand; } });
|
|
8
|
+
var parse_1 = require("./parse");
|
|
9
|
+
Object.defineProperty(exports, "parseSessionCommand", { enumerable: true, get: function () { return parse_1.parseSessionCommand; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseSessionCommand = parseSessionCommand;
|
|
4
|
+
function parseSessionCommand(input, specs) {
|
|
5
|
+
const trimmed = input.trim();
|
|
6
|
+
if (!trimmed.startsWith('/'))
|
|
7
|
+
return { kind: 'text', text: input };
|
|
8
|
+
const raw = trimmed.split(/\s+/, 1)[0];
|
|
9
|
+
const normalized = raw.toLowerCase();
|
|
10
|
+
for (const spec of specs) {
|
|
11
|
+
const names = [spec.name, ...(spec.aliases ?? [])].map(name => `/${name.toLowerCase()}`);
|
|
12
|
+
if (names.includes(normalized))
|
|
13
|
+
return { kind: 'command', name: spec.name, raw };
|
|
14
|
+
}
|
|
15
|
+
return { kind: 'unknown', raw };
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dayloom",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.1",
|
|
4
4
|
"description": "File-based AI life simulation and diary engine.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"prepare": "npm run build",
|
|
12
12
|
"start": "node dist/index.js",
|
|
13
13
|
"dev": "ts-node src/index.ts",
|
|
14
|
-
"test": "npm run build && node --test test/init/*.test.js test/revise/*.test.js test/daily/*.test.js test/play/*.test.js test/settle/*.test.js test/next/*.test.js test/i18n/*.test.js"
|
|
14
|
+
"test": "npm run build && node --test test/init/*.test.js test/revise/*.test.js test/daily/*.test.js test/play/*.test.js test/settle/*.test.js test/next/*.test.js test/i18n/*.test.js test/session-commands/*.test.js"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"dayloom",
|