kaizenai 0.2.1 → 0.2.2

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.
@@ -1,30 +1,56 @@
1
- export const CLI_CHILD_MODE_ENV_VAR = "KAIZEN_CLI_MODE"
2
- export const CLI_CHILD_MODE = "child"
3
- export const CLI_STARTUP_UPDATE_RESTART_EXIT_CODE = 75
4
- export const CLI_UI_UPDATE_RESTART_EXIT_CODE = 76
5
- export const CLI_CHILD_COMMAND_ENV_VAR = "KAIZEN_CLI_CHILD_COMMAND"
6
- export const CLI_CHILD_ARGS_ENV_VAR = "KAIZEN_CLI_CHILD_ARGS"
7
- export const CLI_SUPPRESS_OPEN_ONCE_ENV_VAR = "KAIZEN_SUPPRESS_OPEN_ONCE"
1
+ export const CLI_CHILD_MODE_ENV_VAR = 'KAIZEN_CLI_MODE';
2
+ export const CLI_CHILD_MODE = 'child';
3
+ export const CLI_STARTUP_UPDATE_RESTART_EXIT_CODE = 75;
4
+ export const CLI_UI_UPDATE_RESTART_EXIT_CODE = 76;
5
+ export const CLI_CHILD_COMMAND_ENV_VAR = 'KAIZEN_CLI_CHILD_COMMAND';
6
+ export const CLI_CHILD_ARGS_ENV_VAR = 'KAIZEN_CLI_CHILD_ARGS';
7
+ export const CLI_SUPPRESS_OPEN_ONCE_ENV_VAR = 'KAIZEN_SUPPRESS_OPEN_ONCE';
8
+ export const CLI_SKIP_STARTUP_UPDATE_ONCE_ENV_VAR =
9
+ 'KAIZEN_SKIP_STARTUP_UPDATE_ONCE';
8
10
 
9
- export function shouldRestartCliProcess(code: number | null, signal: NodeJS.Signals | null) {
10
- return signal === null && (code === CLI_STARTUP_UPDATE_RESTART_EXIT_CODE || code === CLI_UI_UPDATE_RESTART_EXIT_CODE)
11
+ export function shouldRestartCliProcess(
12
+ code: number | null,
13
+ signal: NodeJS.Signals | null
14
+ ) {
15
+ return (
16
+ signal === null &&
17
+ (code === CLI_STARTUP_UPDATE_RESTART_EXIT_CODE ||
18
+ code === CLI_UI_UPDATE_RESTART_EXIT_CODE)
19
+ );
11
20
  }
12
21
 
13
- export function isUiUpdateRestart(code: number | null, signal: NodeJS.Signals | null) {
14
- return signal === null && code === CLI_UI_UPDATE_RESTART_EXIT_CODE
22
+ export function isStartupUpdateRestart(
23
+ code: number | null,
24
+ signal: NodeJS.Signals | null
25
+ ) {
26
+ return signal === null && code === CLI_STARTUP_UPDATE_RESTART_EXIT_CODE;
27
+ }
28
+
29
+ export function isUiUpdateRestart(
30
+ code: number | null,
31
+ signal: NodeJS.Signals | null
32
+ ) {
33
+ return signal === null && code === CLI_UI_UPDATE_RESTART_EXIT_CODE;
34
+ }
35
+
36
+ export function shouldSkipStartupUpdateOnce(value: string | undefined) {
37
+ return value === '1';
15
38
  }
16
39
 
17
40
  export function parseChildArgsEnv(value: string | undefined) {
18
- if (!value) return []
41
+ if (!value) return [];
19
42
 
20
43
  try {
21
- const parsed = JSON.parse(value) as unknown
22
- if (!Array.isArray(parsed) || !parsed.every((entry) => typeof entry === "string")) {
23
- throw new Error("child args must be an array of strings")
44
+ const parsed = JSON.parse(value) as unknown;
45
+ if (
46
+ !Array.isArray(parsed) ||
47
+ !parsed.every((entry) => typeof entry === 'string')
48
+ ) {
49
+ throw new Error('child args must be an array of strings');
24
50
  }
25
- return parsed
51
+ return parsed;
26
52
  } catch (error) {
27
- const message = error instanceof Error ? error.message : String(error)
28
- throw new Error(`Invalid ${CLI_CHILD_ARGS_ENV_VAR}: ${message}`)
53
+ const message = error instanceof Error ? error.message : String(error);
54
+ throw new Error(`Invalid ${CLI_CHILD_ARGS_ENV_VAR}: ${message}`);
29
55
  }
30
56
  }
@@ -553,15 +553,7 @@ export function createWsRouter({
553
553
  break
554
554
  }
555
555
  case "chat.create": {
556
- // Reuse an existing empty chat for this project+feature if one exists
557
- const existingChats = store.listChatsByProject(command.projectId)
558
- const emptyChat = existingChats.find((chat) => {
559
- if (chat.lastMessageAt != null) return false
560
- const chatFeatureId = chat.featureId ?? undefined
561
- return chatFeatureId === (command.featureId ?? undefined)
562
- })
563
-
564
- const chat = emptyChat ?? await store.createChat(command.projectId, command.featureId)
556
+ const chat = await store.createChat(command.projectId, command.featureId)
565
557
  send(ws, { v: PROTOCOL_VERSION, type: "ack", id, result: { chatId: chat.id } })
566
558
  break
567
559
  }