@onmars/lunar-core 0.1.0
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/LICENSE +21 -0
- package/README.md +13 -0
- package/package.json +32 -0
- package/src/__tests__/clear-command.test.ts +214 -0
- package/src/__tests__/command-handler.test.ts +169 -0
- package/src/__tests__/compact-command.test.ts +80 -0
- package/src/__tests__/config-command.test.ts +240 -0
- package/src/__tests__/config-loader.test.ts +1512 -0
- package/src/__tests__/config.test.ts +429 -0
- package/src/__tests__/cron-command.test.ts +418 -0
- package/src/__tests__/cron-parser.test.ts +259 -0
- package/src/__tests__/daemon.test.ts +346 -0
- package/src/__tests__/dedup.test.ts +404 -0
- package/src/__tests__/e2e-sanitization.ts +168 -0
- package/src/__tests__/e2e-skill-loader.test.ts +176 -0
- package/src/__tests__/fixtures/AGENTS.md +4 -0
- package/src/__tests__/fixtures/IDENTITY.md +2 -0
- package/src/__tests__/fixtures/SOUL.md +3 -0
- package/src/__tests__/fixtures/moons/athena/IDENTITY.md +2 -0
- package/src/__tests__/fixtures/moons/athena/SOUL.md +3 -0
- package/src/__tests__/fixtures/moons/hermes/SOUL.md +3 -0
- package/src/__tests__/fixtures/skills/brain/SKILL.md +6 -0
- package/src/__tests__/fixtures/skills/empty/SKILL.md +3 -0
- package/src/__tests__/fixtures/skills/multiline/SKILL.md +7 -0
- package/src/__tests__/fixtures/skills/no-desc/SKILL.md +5 -0
- package/src/__tests__/fixtures/skills/notion/SKILL.md +6 -0
- package/src/__tests__/fixtures/skills/quoted/SKILL.md +6 -0
- package/src/__tests__/hook-runner.test.ts +1689 -0
- package/src/__tests__/input-sanitization.test.ts +367 -0
- package/src/__tests__/logger.test.ts +163 -0
- package/src/__tests__/memory-orchestrator.test.ts +552 -0
- package/src/__tests__/model-catalog.test.ts +215 -0
- package/src/__tests__/model-command.test.ts +185 -0
- package/src/__tests__/moon-loader.test.ts +398 -0
- package/src/__tests__/ping-command.test.ts +85 -0
- package/src/__tests__/plugin.test.ts +258 -0
- package/src/__tests__/remind-command.test.ts +368 -0
- package/src/__tests__/reset-command.test.ts +92 -0
- package/src/__tests__/router.test.ts +1246 -0
- package/src/__tests__/scheduler.test.ts +469 -0
- package/src/__tests__/security.test.ts +214 -0
- package/src/__tests__/session-meta.test.ts +101 -0
- package/src/__tests__/session-tracker.test.ts +389 -0
- package/src/__tests__/session.test.ts +241 -0
- package/src/__tests__/skill-loader.test.ts +153 -0
- package/src/__tests__/status-command.test.ts +153 -0
- package/src/__tests__/stop-command.test.ts +60 -0
- package/src/__tests__/think-command.test.ts +146 -0
- package/src/__tests__/usage-api.test.ts +222 -0
- package/src/__tests__/usage-command-api-fail.test.ts +48 -0
- package/src/__tests__/usage-command-no-oauth.test.ts +48 -0
- package/src/__tests__/usage-command.test.ts +173 -0
- package/src/__tests__/whoami-command.test.ts +124 -0
- package/src/index.ts +122 -0
- package/src/lib/command-handler.ts +135 -0
- package/src/lib/commands/clear.ts +69 -0
- package/src/lib/commands/compact.ts +14 -0
- package/src/lib/commands/config-show.ts +49 -0
- package/src/lib/commands/cron.ts +118 -0
- package/src/lib/commands/help.ts +26 -0
- package/src/lib/commands/model.ts +71 -0
- package/src/lib/commands/ping.ts +24 -0
- package/src/lib/commands/remind.ts +75 -0
- package/src/lib/commands/status.ts +118 -0
- package/src/lib/commands/stop.ts +18 -0
- package/src/lib/commands/think.ts +42 -0
- package/src/lib/commands/usage.ts +56 -0
- package/src/lib/commands/whoami.ts +23 -0
- package/src/lib/config-loader.ts +1449 -0
- package/src/lib/config.ts +202 -0
- package/src/lib/cron-parser.ts +388 -0
- package/src/lib/daemon.ts +216 -0
- package/src/lib/dedup.ts +414 -0
- package/src/lib/hook-runner.ts +1270 -0
- package/src/lib/logger.ts +55 -0
- package/src/lib/memory-orchestrator.ts +415 -0
- package/src/lib/model-catalog.ts +240 -0
- package/src/lib/moon-loader.ts +291 -0
- package/src/lib/plugin.ts +148 -0
- package/src/lib/router.ts +1135 -0
- package/src/lib/scheduler.ts +422 -0
- package/src/lib/security.ts +259 -0
- package/src/lib/session-tracker.ts +222 -0
- package/src/lib/session.ts +158 -0
- package/src/lib/skill-loader.ts +166 -0
- package/src/lib/usage-api.ts +145 -0
- package/src/types/agent.ts +86 -0
- package/src/types/channel.ts +93 -0
- package/src/types/index.ts +32 -0
- package/src/types/memory.ts +92 -0
- package/src/types/moon.ts +56 -0
- package/src/types/voice.ts +74 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /reset Command — Test Suite
|
|
3
|
+
*
|
|
4
|
+
* Spec: /reset is an alias for /clear, using the same handler function.
|
|
5
|
+
*
|
|
6
|
+
* Key contracts:
|
|
7
|
+
* - /reset delegates to the clearCommand handler
|
|
8
|
+
* - The command is registered in CommandHandler
|
|
9
|
+
*/
|
|
10
|
+
import { describe, expect, test } from 'bun:test'
|
|
11
|
+
import type { CommandContext } from '../lib/command-handler'
|
|
12
|
+
import { CommandHandler } from '../lib/command-handler'
|
|
13
|
+
import { clearCommand } from '../lib/commands/clear'
|
|
14
|
+
import { SessionTracker } from '../lib/session-tracker'
|
|
15
|
+
|
|
16
|
+
function makeCtx(overrides?: Partial<CommandContext>): CommandContext {
|
|
17
|
+
return {
|
|
18
|
+
sessionKey: 'test:channel-1',
|
|
19
|
+
message: {
|
|
20
|
+
id: 'msg-1',
|
|
21
|
+
channelId: 'channel-1',
|
|
22
|
+
sender: { id: 'user-1', name: 'Test User' },
|
|
23
|
+
text: '/reset',
|
|
24
|
+
timestamp: new Date(),
|
|
25
|
+
},
|
|
26
|
+
tracker: new SessionTracker(),
|
|
27
|
+
daemonStartedAt: Date.now(),
|
|
28
|
+
agent: { id: 'claude', name: 'Claude Code (CLI)' },
|
|
29
|
+
clearSession: async () => ({ sessionCleared: true, hooksRan: false }),
|
|
30
|
+
...overrides,
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ═══════════════════════════════════════════════════════════
|
|
35
|
+
// Registration
|
|
36
|
+
// ═══════════════════════════════════════════════════════════
|
|
37
|
+
|
|
38
|
+
describe('/reset registration', () => {
|
|
39
|
+
test('command is recognized after registration', () => {
|
|
40
|
+
const handler = new CommandHandler()
|
|
41
|
+
handler.register('reset', 'Reset session (alias for /clear)', clearCommand)
|
|
42
|
+
|
|
43
|
+
expect(handler.isCommand('/reset')).toBe(true)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test('command appears in list', () => {
|
|
47
|
+
const handler = new CommandHandler()
|
|
48
|
+
handler.register('reset', 'Reset session (alias for /clear)', clearCommand)
|
|
49
|
+
|
|
50
|
+
const commands = handler.list()
|
|
51
|
+
const resetCmd = commands.find((c) => c.name === 'reset')
|
|
52
|
+
expect(resetCmd).toBeDefined()
|
|
53
|
+
expect(resetCmd!.description).toContain('alias')
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
// ═══════════════════════════════════════════════════════════
|
|
58
|
+
// Delegation
|
|
59
|
+
// ═══════════════════════════════════════════════════════════
|
|
60
|
+
|
|
61
|
+
describe('/reset delegates to clearCommand', () => {
|
|
62
|
+
test('calls clearSession when handled via CommandHandler', async () => {
|
|
63
|
+
let clearCalled = false
|
|
64
|
+
const handler = new CommandHandler()
|
|
65
|
+
handler.register('reset', 'Reset session (alias for /clear)', clearCommand)
|
|
66
|
+
|
|
67
|
+
const ctx = makeCtx({
|
|
68
|
+
clearSession: async () => {
|
|
69
|
+
clearCalled = true
|
|
70
|
+
return { sessionCleared: true, hooksRan: false }
|
|
71
|
+
},
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const result = await handler.handle('/reset', ctx)
|
|
75
|
+
expect(clearCalled).toBe(true)
|
|
76
|
+
expect(result).toContain('Session Cleared')
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
test('produces the same output as /clear', async () => {
|
|
80
|
+
const handler = new CommandHandler()
|
|
81
|
+
handler.register('reset', 'Reset session (alias for /clear)', clearCommand)
|
|
82
|
+
handler.register('clear', 'Clear session', clearCommand)
|
|
83
|
+
|
|
84
|
+
const ctx1 = makeCtx()
|
|
85
|
+
const ctx2 = makeCtx()
|
|
86
|
+
|
|
87
|
+
const resetResult = await handler.handle('/reset', ctx1)
|
|
88
|
+
const clearResult = await handler.handle('/clear', ctx2)
|
|
89
|
+
|
|
90
|
+
expect(resetResult).toEqual(clearResult)
|
|
91
|
+
})
|
|
92
|
+
})
|