zerg-status 1.0.0 → 1.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.
@@ -1 +1 @@
1
- export declare function init(): void;
1
+ export declare function init(name?: string): void;
@@ -1,6 +1,8 @@
1
1
  import { createSession } from '../state.js';
2
2
  import { formatSessionOutput } from '../output.js';
3
- export function init() {
4
- const sessionId = createSession();
5
- console.log(formatSessionOutput(sessionId));
3
+ import { validateName } from '../validate.js';
4
+ export function init(name) {
5
+ const validatedName = name ? validateName(name) : undefined;
6
+ const { sessionId, name: sessionName } = createSession(validatedName);
7
+ console.log(formatSessionOutput(sessionId, sessionName));
6
8
  }
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * zerg-status - Progress reporting CLI for Zerg dashboard
4
4
  *
5
5
  * Usage:
6
+ * npx zerg-status init "Session Name" # Initialize session with name
6
7
  * npx zerg-status init # Initialize session, outputs ZERG_SESSION:<id>
7
8
  * npx zerg-status -s <id> state work # Set state to work/ask/done
8
9
  * npx zerg-status -s <id> state ask "Question?" # Set state to ask with a question
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  * zerg-status - Progress reporting CLI for Zerg dashboard
4
4
  *
5
5
  * Usage:
6
+ * npx zerg-status init "Session Name" # Initialize session with name
6
7
  * npx zerg-status init # Initialize session, outputs ZERG_SESSION:<id>
7
8
  * npx zerg-status -s <id> state work # Set state to work/ask/done
8
9
  * npx zerg-status -s <id> state ask "Question?" # Set state to ask with a question
@@ -49,6 +50,7 @@ function printHelp() {
49
50
  zerg-status - Progress reporting CLI for Zerg dashboard
50
51
 
51
52
  COMMANDS:
53
+ init "Session Name" Initialize new session with name (outputs ZERG_SESSION:<id>:<name>)
52
54
  init Initialize new session (outputs ZERG_SESSION:<id>)
53
55
 
54
56
  -s <id> state <work|ask|done> Set session state
@@ -67,8 +69,8 @@ COMMANDS:
67
69
  -s <id> tasks set "A" "B" "C" Replace all tasks (max 20 tasks)
68
70
 
69
71
  EXAMPLES:
70
- npx zerg-status init
71
- # ZERG_SESSION:f7a3b2c1
72
+ npx zerg-status init "Fix auth bug"
73
+ # ZERG_SESSION:f7a3b2c1:Fix auth bug
72
74
 
73
75
  npx zerg-status -s f7a3b2c1 state work
74
76
  npx zerg-status -s f7a3b2c1 now "Writing unit tests"
@@ -78,7 +80,7 @@ EXAMPLES:
78
80
  npx zerg-status -s f7a3b2c1 state done
79
81
 
80
82
  OUTPUT:
81
- init outputs: ZERG_SESSION:<session_id>
83
+ init outputs: ZERG_SESSION:<session_id>[:<name>]
82
84
  all others: ZERG_STATUS:<full_json_state>
83
85
  `);
84
86
  }
@@ -86,9 +88,11 @@ function main() {
86
88
  try {
87
89
  const { sessionId, command, args } = parseArgs(process.argv);
88
90
  switch (command) {
89
- case 'init':
90
- init();
91
+ case 'init': {
92
+ const name = args.join(' ') || undefined;
93
+ init(name);
91
94
  break;
95
+ }
92
96
  case 'state': {
93
97
  const validSessionId = validateSessionId(sessionId);
94
98
  const [stateValue, ...rest] = args;
package/dist/output.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { ZergState } from './types.js';
2
- export declare function formatSessionOutput(sessionId: string): string;
2
+ export declare function formatSessionOutput(sessionId: string, name?: string): string;
3
3
  export declare function formatStatusOutput(state: ZergState): string;
package/dist/output.js CHANGED
@@ -1,4 +1,7 @@
1
- export function formatSessionOutput(sessionId) {
1
+ export function formatSessionOutput(sessionId, name) {
2
+ if (name) {
3
+ return `ZERG_SESSION:${sessionId}:${name}`;
4
+ }
2
5
  return `ZERG_SESSION:${sessionId}`;
3
6
  }
4
7
  export function formatStatusOutput(state) {
package/dist/state.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import type { ZergState, State, TaskStatus } from './types.js';
2
2
  export declare function generateSessionId(): string;
3
- export declare function createSession(): string;
3
+ export declare function createSession(name?: string): {
4
+ sessionId: string;
5
+ name?: string;
6
+ };
4
7
  export declare function loadState(sessionId: string): ZergState;
5
8
  export declare function saveState(state: ZergState): void;
6
9
  export declare function updateState(sessionId: string, updates: Partial<ZergState>): ZergState;
package/dist/state.js CHANGED
@@ -16,15 +16,16 @@ function getStatePath(sessionId) {
16
16
  export function generateSessionId() {
17
17
  return crypto.randomBytes(4).toString('hex');
18
18
  }
19
- export function createSession() {
19
+ export function createSession(name) {
20
20
  ensureStateDir();
21
21
  const sessionId = generateSessionId();
22
22
  const state = {
23
23
  session: sessionId,
24
+ name,
24
25
  ...DEFAULT_STATE,
25
26
  };
26
27
  fs.writeFileSync(getStatePath(sessionId), JSON.stringify(state, null, 2));
27
- return sessionId;
28
+ return { sessionId, name };
28
29
  }
29
30
  export function loadState(sessionId) {
30
31
  ensureStateDir();
package/dist/types.d.ts CHANGED
@@ -6,6 +6,7 @@ export interface Task {
6
6
  }
7
7
  export interface ZergState {
8
8
  session: string;
9
+ name?: string;
9
10
  state: State;
10
11
  now: string;
11
12
  summary: string;
@@ -5,6 +5,8 @@ export declare const MAX_NOW_LENGTH = 50;
5
5
  export declare const MAX_SUMMARY_LENGTH = 500;
6
6
  export declare const MAX_TASK_LENGTH = 200;
7
7
  export declare const MAX_TASKS = 20;
8
+ export declare const MAX_NAME_LENGTH = 60;
9
+ export declare const MAX_NAME_WORDS = 6;
8
10
  export declare class ValidationError extends Error {
9
11
  constructor(message: string);
10
12
  }
@@ -15,3 +17,4 @@ export declare function validateSummary(summary: string): string;
15
17
  export declare function validateTask(task: string): string;
16
18
  export declare function validateTaskCount(count: number): void;
17
19
  export declare function validateSessionId(sessionId: string | undefined): string;
20
+ export declare function validateName(name: string): string;
package/dist/validate.js CHANGED
@@ -4,6 +4,8 @@ export const MAX_NOW_LENGTH = 50;
4
4
  export const MAX_SUMMARY_LENGTH = 500;
5
5
  export const MAX_TASK_LENGTH = 200;
6
6
  export const MAX_TASKS = 20;
7
+ export const MAX_NAME_LENGTH = 60;
8
+ export const MAX_NAME_WORDS = 6;
7
9
  export class ValidationError extends Error {
8
10
  constructor(message) {
9
11
  super(message);
@@ -51,3 +53,13 @@ export function validateSessionId(sessionId) {
51
53
  }
52
54
  return sessionId;
53
55
  }
56
+ export function validateName(name) {
57
+ if (name.length > MAX_NAME_LENGTH) {
58
+ throw new ValidationError(`Name too long (${name.length} chars). Max ${MAX_NAME_LENGTH} chars.`);
59
+ }
60
+ const wordCount = name.trim().split(/\s+/).length;
61
+ if (wordCount > MAX_NAME_WORDS) {
62
+ throw new ValidationError(`Name has too many words (${wordCount}). Max ${MAX_NAME_WORDS} words.`);
63
+ }
64
+ return name;
65
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zerg-status",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Progress reporting CLI for Zerg dashboard",
5
5
  "type": "module",
6
6
  "bin": {