dev-sesssion 1.0.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/dist/index.cjs +24938 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +333 -0
- package/dist/index.d.ts +333 -0
- package/dist/index.mjs +24925 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +44 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Commander program setup for the dev-session CLI.
|
|
5
|
+
*
|
|
6
|
+
* Defines the root program with global options and registers all
|
|
7
|
+
* subcommands. This module owns the Commander instance — `index.ts`
|
|
8
|
+
* imports and runs it.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Create and configure the Commander program.
|
|
15
|
+
*
|
|
16
|
+
* @returns The configured Commander program (not yet parsed)
|
|
17
|
+
*/
|
|
18
|
+
declare function createProgram(): Command;
|
|
19
|
+
/**
|
|
20
|
+
* Parse arguments and run the CLI.
|
|
21
|
+
*
|
|
22
|
+
* Installs signal handlers, creates the program, parses argv,
|
|
23
|
+
* and handles any uncaught errors.
|
|
24
|
+
*
|
|
25
|
+
* @param argv - Process arguments (defaults to process.argv)
|
|
26
|
+
* @returns Promise that resolves when the command completes
|
|
27
|
+
*/
|
|
28
|
+
declare function run(argv?: readonly string[]): Promise<void>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* `dev-session advance` command.
|
|
32
|
+
*
|
|
33
|
+
* Archives the current chunk, compacts session state, advances to the
|
|
34
|
+
* next chunk, and regenerates NEXT_PROMPT.md. Warns if not all tasks in
|
|
35
|
+
* the active chunk are done, prompting for confirmation to force-advance.
|
|
36
|
+
*
|
|
37
|
+
* Business logic lives in @dev-session/core — this module handles CLI
|
|
38
|
+
* prompts, formatting, and orchestration.
|
|
39
|
+
*
|
|
40
|
+
* @module
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/** Options passed from Commander to the advance action. */
|
|
44
|
+
interface AdvanceOptions {
|
|
45
|
+
/** Working directory override. */
|
|
46
|
+
readonly cwd: string;
|
|
47
|
+
/** Skip prompts and force-advance even with incomplete tasks. */
|
|
48
|
+
readonly yes: boolean;
|
|
49
|
+
/** Show detailed output. */
|
|
50
|
+
readonly verbose: boolean;
|
|
51
|
+
/** Explicit adapter override (from --adapter flag). */
|
|
52
|
+
readonly adapter?: string;
|
|
53
|
+
}
|
|
54
|
+
/** Result returned after an advance run. */
|
|
55
|
+
interface AdvanceResult {
|
|
56
|
+
/** The chunk ID that was archived. */
|
|
57
|
+
readonly archivedChunkId: number;
|
|
58
|
+
/** The new active chunk ID. */
|
|
59
|
+
readonly newChunkId: number;
|
|
60
|
+
/** Title of the new active chunk. */
|
|
61
|
+
readonly newChunkTitle: string;
|
|
62
|
+
/** Number of tasks remaining in the new chunk. */
|
|
63
|
+
readonly tasksRemaining: number;
|
|
64
|
+
/** Whether a force-advance was needed (incomplete tasks). */
|
|
65
|
+
readonly forceAdvanced: boolean;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* `dev-session index` commands: `add` and `audit`.
|
|
70
|
+
*
|
|
71
|
+
* - `add <filepath>` — validate and append a file to FILE_INDEX.md
|
|
72
|
+
* - `audit` — detect stale entries and optionally auto-remove them
|
|
73
|
+
*
|
|
74
|
+
* Business logic lives in @dev-session/core — this module handles CLI
|
|
75
|
+
* prompts, formatting, and Commander registration.
|
|
76
|
+
*
|
|
77
|
+
* @module
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
/** Options for the index add subcommand. */
|
|
81
|
+
interface IndexAddOptions {
|
|
82
|
+
/** Working directory override. */
|
|
83
|
+
readonly cwd: string;
|
|
84
|
+
/** The file path to add. */
|
|
85
|
+
readonly filepath: string;
|
|
86
|
+
/** Skip prompts and use defaults. */
|
|
87
|
+
readonly yes: boolean;
|
|
88
|
+
/** Show detailed output. */
|
|
89
|
+
readonly verbose: boolean;
|
|
90
|
+
}
|
|
91
|
+
/** Options for the index audit subcommand. */
|
|
92
|
+
interface IndexAuditOptions {
|
|
93
|
+
/** Working directory override. */
|
|
94
|
+
readonly cwd: string;
|
|
95
|
+
/** Automatically remove stale entries after confirmation. */
|
|
96
|
+
readonly fix: boolean;
|
|
97
|
+
/** Skip prompts (auto-confirm removals). */
|
|
98
|
+
readonly yes: boolean;
|
|
99
|
+
/** Show detailed output. */
|
|
100
|
+
readonly verbose: boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* `dev-session init` command.
|
|
105
|
+
*
|
|
106
|
+
* Orchestrates the full init wizard: detection, migration path selection,
|
|
107
|
+
* plan splitting or scaffolding, FILE_INDEX generation, and final writes.
|
|
108
|
+
*
|
|
109
|
+
* Business logic lives in @dev-session/core -- this module only handles
|
|
110
|
+
* CLI prompts, formatting, and file write orchestration.
|
|
111
|
+
*
|
|
112
|
+
* @module
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
/** Options passed from commander to the init action. */
|
|
116
|
+
interface InitOptions {
|
|
117
|
+
/** Working directory override. */
|
|
118
|
+
readonly cwd: string;
|
|
119
|
+
/** Skip all prompts and use defaults. */
|
|
120
|
+
readonly yes: boolean;
|
|
121
|
+
/** Log writes without touching the filesystem. */
|
|
122
|
+
readonly dryRun: boolean;
|
|
123
|
+
/** Show verbose output. */
|
|
124
|
+
readonly verbose: boolean;
|
|
125
|
+
/** Enable strict mode (block on secret detection). */
|
|
126
|
+
readonly strict: boolean;
|
|
127
|
+
/** Explicit adapter override (from --adapter flag). */
|
|
128
|
+
readonly adapter?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Explicitly enable team mode (auto-applies .gitignore + .gitattributes).
|
|
131
|
+
* When undefined and not --yes, the wizard prompts for team vs personal.
|
|
132
|
+
*/
|
|
133
|
+
readonly teamMode?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Cap the number of files indexed during FILE_INDEX generation.
|
|
136
|
+
* When undefined, all discovered files are indexed.
|
|
137
|
+
*/
|
|
138
|
+
readonly maxFiles?: number;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* `dev-session prompt` command.
|
|
143
|
+
*
|
|
144
|
+
* Prints the contents of NEXT_PROMPT.md to stdout for piping or copying.
|
|
145
|
+
* Supports a `--copy` flag that copies to the system clipboard using
|
|
146
|
+
* platform-native commands (pbcopy on macOS, xclip/xsel on Linux,
|
|
147
|
+
* clip.exe on Windows).
|
|
148
|
+
*
|
|
149
|
+
* @module
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
/** Options passed from Commander to the prompt action. */
|
|
153
|
+
interface PromptOptions {
|
|
154
|
+
/** Working directory override. */
|
|
155
|
+
readonly cwd: string;
|
|
156
|
+
/** Copy prompt to system clipboard. */
|
|
157
|
+
readonly copy: boolean;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* `dev-session status` command.
|
|
162
|
+
*
|
|
163
|
+
* Reads the session state, active plan chunk, and file index to display
|
|
164
|
+
* a rich status overview: task completion percentage, context budget
|
|
165
|
+
* breakdown, health warnings, and optional JSON output.
|
|
166
|
+
*
|
|
167
|
+
* Business logic lives in @dev-session/core — this module handles CLI
|
|
168
|
+
* display formatting and Commander registration.
|
|
169
|
+
*
|
|
170
|
+
* @module
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
/** Options passed from Commander to the status action. */
|
|
174
|
+
interface StatusOptions {
|
|
175
|
+
/** Working directory override. */
|
|
176
|
+
readonly cwd: string;
|
|
177
|
+
/** Output machine-readable JSON. */
|
|
178
|
+
readonly json: boolean;
|
|
179
|
+
/** Show verbose output. */
|
|
180
|
+
readonly verbose: boolean;
|
|
181
|
+
}
|
|
182
|
+
/** JSON-serializable status output for --json flag. */
|
|
183
|
+
interface StatusJson {
|
|
184
|
+
readonly active_chunk: number;
|
|
185
|
+
readonly chunk_title: string;
|
|
186
|
+
readonly session_id: string;
|
|
187
|
+
readonly last_updated: string;
|
|
188
|
+
readonly tasks: {
|
|
189
|
+
readonly total: number;
|
|
190
|
+
readonly done: number;
|
|
191
|
+
readonly in_progress: number;
|
|
192
|
+
readonly todo: number;
|
|
193
|
+
readonly percent_complete: number;
|
|
194
|
+
};
|
|
195
|
+
readonly files: {
|
|
196
|
+
readonly always_include: number;
|
|
197
|
+
readonly indexed: number;
|
|
198
|
+
readonly context: number;
|
|
199
|
+
};
|
|
200
|
+
readonly budget: {
|
|
201
|
+
readonly total_tokens: number;
|
|
202
|
+
readonly budget_cap: number;
|
|
203
|
+
readonly over_budget: boolean;
|
|
204
|
+
readonly accurate: boolean;
|
|
205
|
+
};
|
|
206
|
+
readonly warnings: readonly string[];
|
|
207
|
+
readonly days_since_last_session: number | null;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* `dev-session update` command.
|
|
212
|
+
*
|
|
213
|
+
* Interactive task marking, note adding, "last worked" file updates,
|
|
214
|
+
* prompt regeneration, and secret scanning. In `--yes` mode, only
|
|
215
|
+
* auto-detectable updates are applied (git status for last-worked files).
|
|
216
|
+
*
|
|
217
|
+
* Business logic lives in @dev-session/core — this module handles CLI
|
|
218
|
+
* prompts, formatting, and file write orchestration.
|
|
219
|
+
*
|
|
220
|
+
* @module
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
/** Options passed from Commander to the update action. */
|
|
224
|
+
interface UpdateOptions {
|
|
225
|
+
/** Working directory override. */
|
|
226
|
+
readonly cwd: string;
|
|
227
|
+
/** Skip prompts and apply auto-detectable updates only. */
|
|
228
|
+
readonly yes: boolean;
|
|
229
|
+
/** Show detailed output. */
|
|
230
|
+
readonly verbose: boolean;
|
|
231
|
+
/** Enable strict mode (block on secret detection). */
|
|
232
|
+
readonly strict: boolean;
|
|
233
|
+
/** Explicit adapter override (from --adapter flag). */
|
|
234
|
+
readonly adapter?: string;
|
|
235
|
+
}
|
|
236
|
+
/** Result returned after an update run. */
|
|
237
|
+
interface UpdateResult {
|
|
238
|
+
/** Number of tasks whose status was changed. */
|
|
239
|
+
readonly tasksUpdated: number;
|
|
240
|
+
/** Number of notes added. */
|
|
241
|
+
readonly notesAdded: number;
|
|
242
|
+
/** Whether the last-worked file list was changed. */
|
|
243
|
+
readonly lastWorkedUpdated: boolean;
|
|
244
|
+
/** Whether NEXT_PROMPT.md was regenerated. */
|
|
245
|
+
readonly promptRegenerated: boolean;
|
|
246
|
+
/** Number of secret scan warnings found. */
|
|
247
|
+
readonly secretWarnings: number;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Dry-run file write proxy.
|
|
252
|
+
*
|
|
253
|
+
* When `--dry-run` is active, replaces actual file writes with log output
|
|
254
|
+
* showing what would be written. All methods mirror the AtomicWriter API
|
|
255
|
+
* but only log — no filesystem changes.
|
|
256
|
+
*
|
|
257
|
+
* @module
|
|
258
|
+
*/
|
|
259
|
+
/**
|
|
260
|
+
* Log what a file write would produce without actually writing.
|
|
261
|
+
*
|
|
262
|
+
* @param filePath - The target file path
|
|
263
|
+
* @param content - The content that would be written
|
|
264
|
+
* @param cwd - The working directory (for relative path display)
|
|
265
|
+
*/
|
|
266
|
+
declare function dryRunWrite(filePath: string, content: string, cwd: string): void;
|
|
267
|
+
/**
|
|
268
|
+
* Log what a directory creation would produce without actually creating.
|
|
269
|
+
*
|
|
270
|
+
* @param dirPath - The target directory path
|
|
271
|
+
* @param cwd - The working directory (for relative path display)
|
|
272
|
+
*/
|
|
273
|
+
declare function dryRunMkdir(dirPath: string, cwd: string): void;
|
|
274
|
+
/**
|
|
275
|
+
* Log what a .gitignore patch would produce without actually patching.
|
|
276
|
+
*
|
|
277
|
+
* @param filePath - The .gitignore file path
|
|
278
|
+
* @param entries - Lines that would be appended
|
|
279
|
+
* @param cwd - The working directory (for relative path display)
|
|
280
|
+
*/
|
|
281
|
+
declare function dryRunGitignorePatch(filePath: string, entries: readonly string[], cwd: string): void;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Global error handler for the dev-session CLI.
|
|
285
|
+
*
|
|
286
|
+
* Catches typed errors (CliError, ParseError, SecurityError) and formats
|
|
287
|
+
* them for terminal output. Unrecognized errors get a generic message.
|
|
288
|
+
*
|
|
289
|
+
* @module
|
|
290
|
+
*/
|
|
291
|
+
/**
|
|
292
|
+
* Format and display an error in the terminal, then exit with the
|
|
293
|
+
* appropriate code.
|
|
294
|
+
*
|
|
295
|
+
* @param error - The caught error (typed or unknown)
|
|
296
|
+
* @param opts - Options controlling exit behavior
|
|
297
|
+
* @param opts.exit - Whether to call process.exit (default: true). Set to false in tests.
|
|
298
|
+
* @returns The exit code that was (or would be) used
|
|
299
|
+
*/
|
|
300
|
+
declare function handleError(error: unknown, opts?: {
|
|
301
|
+
exit?: boolean;
|
|
302
|
+
}): number;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Signal handler for graceful cleanup on SIGINT/SIGTERM.
|
|
306
|
+
*
|
|
307
|
+
* Registers cleanup callbacks that run when the process receives an
|
|
308
|
+
* interrupt or termination signal. Uses a re-entrancy guard to prevent
|
|
309
|
+
* double-cleanup. Cleans up partial `.tmp` files from AtomicWriter.
|
|
310
|
+
*
|
|
311
|
+
* @module
|
|
312
|
+
*/
|
|
313
|
+
/** Cleanup callback type. */
|
|
314
|
+
type CleanupFn = () => void | Promise<void>;
|
|
315
|
+
/**
|
|
316
|
+
* Register a cleanup function to run on signal.
|
|
317
|
+
*
|
|
318
|
+
* @param fn - Synchronous or async cleanup callback
|
|
319
|
+
* @returns A dispose function that unregisters the callback
|
|
320
|
+
*/
|
|
321
|
+
declare function onCleanup(fn: CleanupFn): () => void;
|
|
322
|
+
/**
|
|
323
|
+
* Install SIGINT and SIGTERM handlers.
|
|
324
|
+
*
|
|
325
|
+
* Should be called once at CLI startup. Handlers run cleanup functions,
|
|
326
|
+
* print a cancellation message, and exit with code 130 (SIGINT) or
|
|
327
|
+
* 143 (SIGTERM).
|
|
328
|
+
*
|
|
329
|
+
* @returns A dispose function that removes the handlers
|
|
330
|
+
*/
|
|
331
|
+
declare function installSignalHandlers(): () => void;
|
|
332
|
+
|
|
333
|
+
export { type AdvanceOptions, type AdvanceResult, type IndexAddOptions, type IndexAuditOptions, type InitOptions, type PromptOptions, type StatusJson, type StatusOptions, type UpdateOptions, type UpdateResult, createProgram, dryRunGitignorePatch, dryRunMkdir, dryRunWrite, handleError, installSignalHandlers, onCleanup, run };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Commander program setup for the dev-session CLI.
|
|
5
|
+
*
|
|
6
|
+
* Defines the root program with global options and registers all
|
|
7
|
+
* subcommands. This module owns the Commander instance — `index.ts`
|
|
8
|
+
* imports and runs it.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Create and configure the Commander program.
|
|
15
|
+
*
|
|
16
|
+
* @returns The configured Commander program (not yet parsed)
|
|
17
|
+
*/
|
|
18
|
+
declare function createProgram(): Command;
|
|
19
|
+
/**
|
|
20
|
+
* Parse arguments and run the CLI.
|
|
21
|
+
*
|
|
22
|
+
* Installs signal handlers, creates the program, parses argv,
|
|
23
|
+
* and handles any uncaught errors.
|
|
24
|
+
*
|
|
25
|
+
* @param argv - Process arguments (defaults to process.argv)
|
|
26
|
+
* @returns Promise that resolves when the command completes
|
|
27
|
+
*/
|
|
28
|
+
declare function run(argv?: readonly string[]): Promise<void>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* `dev-session advance` command.
|
|
32
|
+
*
|
|
33
|
+
* Archives the current chunk, compacts session state, advances to the
|
|
34
|
+
* next chunk, and regenerates NEXT_PROMPT.md. Warns if not all tasks in
|
|
35
|
+
* the active chunk are done, prompting for confirmation to force-advance.
|
|
36
|
+
*
|
|
37
|
+
* Business logic lives in @dev-session/core — this module handles CLI
|
|
38
|
+
* prompts, formatting, and orchestration.
|
|
39
|
+
*
|
|
40
|
+
* @module
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/** Options passed from Commander to the advance action. */
|
|
44
|
+
interface AdvanceOptions {
|
|
45
|
+
/** Working directory override. */
|
|
46
|
+
readonly cwd: string;
|
|
47
|
+
/** Skip prompts and force-advance even with incomplete tasks. */
|
|
48
|
+
readonly yes: boolean;
|
|
49
|
+
/** Show detailed output. */
|
|
50
|
+
readonly verbose: boolean;
|
|
51
|
+
/** Explicit adapter override (from --adapter flag). */
|
|
52
|
+
readonly adapter?: string;
|
|
53
|
+
}
|
|
54
|
+
/** Result returned after an advance run. */
|
|
55
|
+
interface AdvanceResult {
|
|
56
|
+
/** The chunk ID that was archived. */
|
|
57
|
+
readonly archivedChunkId: number;
|
|
58
|
+
/** The new active chunk ID. */
|
|
59
|
+
readonly newChunkId: number;
|
|
60
|
+
/** Title of the new active chunk. */
|
|
61
|
+
readonly newChunkTitle: string;
|
|
62
|
+
/** Number of tasks remaining in the new chunk. */
|
|
63
|
+
readonly tasksRemaining: number;
|
|
64
|
+
/** Whether a force-advance was needed (incomplete tasks). */
|
|
65
|
+
readonly forceAdvanced: boolean;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* `dev-session index` commands: `add` and `audit`.
|
|
70
|
+
*
|
|
71
|
+
* - `add <filepath>` — validate and append a file to FILE_INDEX.md
|
|
72
|
+
* - `audit` — detect stale entries and optionally auto-remove them
|
|
73
|
+
*
|
|
74
|
+
* Business logic lives in @dev-session/core — this module handles CLI
|
|
75
|
+
* prompts, formatting, and Commander registration.
|
|
76
|
+
*
|
|
77
|
+
* @module
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
/** Options for the index add subcommand. */
|
|
81
|
+
interface IndexAddOptions {
|
|
82
|
+
/** Working directory override. */
|
|
83
|
+
readonly cwd: string;
|
|
84
|
+
/** The file path to add. */
|
|
85
|
+
readonly filepath: string;
|
|
86
|
+
/** Skip prompts and use defaults. */
|
|
87
|
+
readonly yes: boolean;
|
|
88
|
+
/** Show detailed output. */
|
|
89
|
+
readonly verbose: boolean;
|
|
90
|
+
}
|
|
91
|
+
/** Options for the index audit subcommand. */
|
|
92
|
+
interface IndexAuditOptions {
|
|
93
|
+
/** Working directory override. */
|
|
94
|
+
readonly cwd: string;
|
|
95
|
+
/** Automatically remove stale entries after confirmation. */
|
|
96
|
+
readonly fix: boolean;
|
|
97
|
+
/** Skip prompts (auto-confirm removals). */
|
|
98
|
+
readonly yes: boolean;
|
|
99
|
+
/** Show detailed output. */
|
|
100
|
+
readonly verbose: boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* `dev-session init` command.
|
|
105
|
+
*
|
|
106
|
+
* Orchestrates the full init wizard: detection, migration path selection,
|
|
107
|
+
* plan splitting or scaffolding, FILE_INDEX generation, and final writes.
|
|
108
|
+
*
|
|
109
|
+
* Business logic lives in @dev-session/core -- this module only handles
|
|
110
|
+
* CLI prompts, formatting, and file write orchestration.
|
|
111
|
+
*
|
|
112
|
+
* @module
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
/** Options passed from commander to the init action. */
|
|
116
|
+
interface InitOptions {
|
|
117
|
+
/** Working directory override. */
|
|
118
|
+
readonly cwd: string;
|
|
119
|
+
/** Skip all prompts and use defaults. */
|
|
120
|
+
readonly yes: boolean;
|
|
121
|
+
/** Log writes without touching the filesystem. */
|
|
122
|
+
readonly dryRun: boolean;
|
|
123
|
+
/** Show verbose output. */
|
|
124
|
+
readonly verbose: boolean;
|
|
125
|
+
/** Enable strict mode (block on secret detection). */
|
|
126
|
+
readonly strict: boolean;
|
|
127
|
+
/** Explicit adapter override (from --adapter flag). */
|
|
128
|
+
readonly adapter?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Explicitly enable team mode (auto-applies .gitignore + .gitattributes).
|
|
131
|
+
* When undefined and not --yes, the wizard prompts for team vs personal.
|
|
132
|
+
*/
|
|
133
|
+
readonly teamMode?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Cap the number of files indexed during FILE_INDEX generation.
|
|
136
|
+
* When undefined, all discovered files are indexed.
|
|
137
|
+
*/
|
|
138
|
+
readonly maxFiles?: number;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* `dev-session prompt` command.
|
|
143
|
+
*
|
|
144
|
+
* Prints the contents of NEXT_PROMPT.md to stdout for piping or copying.
|
|
145
|
+
* Supports a `--copy` flag that copies to the system clipboard using
|
|
146
|
+
* platform-native commands (pbcopy on macOS, xclip/xsel on Linux,
|
|
147
|
+
* clip.exe on Windows).
|
|
148
|
+
*
|
|
149
|
+
* @module
|
|
150
|
+
*/
|
|
151
|
+
|
|
152
|
+
/** Options passed from Commander to the prompt action. */
|
|
153
|
+
interface PromptOptions {
|
|
154
|
+
/** Working directory override. */
|
|
155
|
+
readonly cwd: string;
|
|
156
|
+
/** Copy prompt to system clipboard. */
|
|
157
|
+
readonly copy: boolean;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* `dev-session status` command.
|
|
162
|
+
*
|
|
163
|
+
* Reads the session state, active plan chunk, and file index to display
|
|
164
|
+
* a rich status overview: task completion percentage, context budget
|
|
165
|
+
* breakdown, health warnings, and optional JSON output.
|
|
166
|
+
*
|
|
167
|
+
* Business logic lives in @dev-session/core — this module handles CLI
|
|
168
|
+
* display formatting and Commander registration.
|
|
169
|
+
*
|
|
170
|
+
* @module
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
/** Options passed from Commander to the status action. */
|
|
174
|
+
interface StatusOptions {
|
|
175
|
+
/** Working directory override. */
|
|
176
|
+
readonly cwd: string;
|
|
177
|
+
/** Output machine-readable JSON. */
|
|
178
|
+
readonly json: boolean;
|
|
179
|
+
/** Show verbose output. */
|
|
180
|
+
readonly verbose: boolean;
|
|
181
|
+
}
|
|
182
|
+
/** JSON-serializable status output for --json flag. */
|
|
183
|
+
interface StatusJson {
|
|
184
|
+
readonly active_chunk: number;
|
|
185
|
+
readonly chunk_title: string;
|
|
186
|
+
readonly session_id: string;
|
|
187
|
+
readonly last_updated: string;
|
|
188
|
+
readonly tasks: {
|
|
189
|
+
readonly total: number;
|
|
190
|
+
readonly done: number;
|
|
191
|
+
readonly in_progress: number;
|
|
192
|
+
readonly todo: number;
|
|
193
|
+
readonly percent_complete: number;
|
|
194
|
+
};
|
|
195
|
+
readonly files: {
|
|
196
|
+
readonly always_include: number;
|
|
197
|
+
readonly indexed: number;
|
|
198
|
+
readonly context: number;
|
|
199
|
+
};
|
|
200
|
+
readonly budget: {
|
|
201
|
+
readonly total_tokens: number;
|
|
202
|
+
readonly budget_cap: number;
|
|
203
|
+
readonly over_budget: boolean;
|
|
204
|
+
readonly accurate: boolean;
|
|
205
|
+
};
|
|
206
|
+
readonly warnings: readonly string[];
|
|
207
|
+
readonly days_since_last_session: number | null;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* `dev-session update` command.
|
|
212
|
+
*
|
|
213
|
+
* Interactive task marking, note adding, "last worked" file updates,
|
|
214
|
+
* prompt regeneration, and secret scanning. In `--yes` mode, only
|
|
215
|
+
* auto-detectable updates are applied (git status for last-worked files).
|
|
216
|
+
*
|
|
217
|
+
* Business logic lives in @dev-session/core — this module handles CLI
|
|
218
|
+
* prompts, formatting, and file write orchestration.
|
|
219
|
+
*
|
|
220
|
+
* @module
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
/** Options passed from Commander to the update action. */
|
|
224
|
+
interface UpdateOptions {
|
|
225
|
+
/** Working directory override. */
|
|
226
|
+
readonly cwd: string;
|
|
227
|
+
/** Skip prompts and apply auto-detectable updates only. */
|
|
228
|
+
readonly yes: boolean;
|
|
229
|
+
/** Show detailed output. */
|
|
230
|
+
readonly verbose: boolean;
|
|
231
|
+
/** Enable strict mode (block on secret detection). */
|
|
232
|
+
readonly strict: boolean;
|
|
233
|
+
/** Explicit adapter override (from --adapter flag). */
|
|
234
|
+
readonly adapter?: string;
|
|
235
|
+
}
|
|
236
|
+
/** Result returned after an update run. */
|
|
237
|
+
interface UpdateResult {
|
|
238
|
+
/** Number of tasks whose status was changed. */
|
|
239
|
+
readonly tasksUpdated: number;
|
|
240
|
+
/** Number of notes added. */
|
|
241
|
+
readonly notesAdded: number;
|
|
242
|
+
/** Whether the last-worked file list was changed. */
|
|
243
|
+
readonly lastWorkedUpdated: boolean;
|
|
244
|
+
/** Whether NEXT_PROMPT.md was regenerated. */
|
|
245
|
+
readonly promptRegenerated: boolean;
|
|
246
|
+
/** Number of secret scan warnings found. */
|
|
247
|
+
readonly secretWarnings: number;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Dry-run file write proxy.
|
|
252
|
+
*
|
|
253
|
+
* When `--dry-run` is active, replaces actual file writes with log output
|
|
254
|
+
* showing what would be written. All methods mirror the AtomicWriter API
|
|
255
|
+
* but only log — no filesystem changes.
|
|
256
|
+
*
|
|
257
|
+
* @module
|
|
258
|
+
*/
|
|
259
|
+
/**
|
|
260
|
+
* Log what a file write would produce without actually writing.
|
|
261
|
+
*
|
|
262
|
+
* @param filePath - The target file path
|
|
263
|
+
* @param content - The content that would be written
|
|
264
|
+
* @param cwd - The working directory (for relative path display)
|
|
265
|
+
*/
|
|
266
|
+
declare function dryRunWrite(filePath: string, content: string, cwd: string): void;
|
|
267
|
+
/**
|
|
268
|
+
* Log what a directory creation would produce without actually creating.
|
|
269
|
+
*
|
|
270
|
+
* @param dirPath - The target directory path
|
|
271
|
+
* @param cwd - The working directory (for relative path display)
|
|
272
|
+
*/
|
|
273
|
+
declare function dryRunMkdir(dirPath: string, cwd: string): void;
|
|
274
|
+
/**
|
|
275
|
+
* Log what a .gitignore patch would produce without actually patching.
|
|
276
|
+
*
|
|
277
|
+
* @param filePath - The .gitignore file path
|
|
278
|
+
* @param entries - Lines that would be appended
|
|
279
|
+
* @param cwd - The working directory (for relative path display)
|
|
280
|
+
*/
|
|
281
|
+
declare function dryRunGitignorePatch(filePath: string, entries: readonly string[], cwd: string): void;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Global error handler for the dev-session CLI.
|
|
285
|
+
*
|
|
286
|
+
* Catches typed errors (CliError, ParseError, SecurityError) and formats
|
|
287
|
+
* them for terminal output. Unrecognized errors get a generic message.
|
|
288
|
+
*
|
|
289
|
+
* @module
|
|
290
|
+
*/
|
|
291
|
+
/**
|
|
292
|
+
* Format and display an error in the terminal, then exit with the
|
|
293
|
+
* appropriate code.
|
|
294
|
+
*
|
|
295
|
+
* @param error - The caught error (typed or unknown)
|
|
296
|
+
* @param opts - Options controlling exit behavior
|
|
297
|
+
* @param opts.exit - Whether to call process.exit (default: true). Set to false in tests.
|
|
298
|
+
* @returns The exit code that was (or would be) used
|
|
299
|
+
*/
|
|
300
|
+
declare function handleError(error: unknown, opts?: {
|
|
301
|
+
exit?: boolean;
|
|
302
|
+
}): number;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Signal handler for graceful cleanup on SIGINT/SIGTERM.
|
|
306
|
+
*
|
|
307
|
+
* Registers cleanup callbacks that run when the process receives an
|
|
308
|
+
* interrupt or termination signal. Uses a re-entrancy guard to prevent
|
|
309
|
+
* double-cleanup. Cleans up partial `.tmp` files from AtomicWriter.
|
|
310
|
+
*
|
|
311
|
+
* @module
|
|
312
|
+
*/
|
|
313
|
+
/** Cleanup callback type. */
|
|
314
|
+
type CleanupFn = () => void | Promise<void>;
|
|
315
|
+
/**
|
|
316
|
+
* Register a cleanup function to run on signal.
|
|
317
|
+
*
|
|
318
|
+
* @param fn - Synchronous or async cleanup callback
|
|
319
|
+
* @returns A dispose function that unregisters the callback
|
|
320
|
+
*/
|
|
321
|
+
declare function onCleanup(fn: CleanupFn): () => void;
|
|
322
|
+
/**
|
|
323
|
+
* Install SIGINT and SIGTERM handlers.
|
|
324
|
+
*
|
|
325
|
+
* Should be called once at CLI startup. Handlers run cleanup functions,
|
|
326
|
+
* print a cancellation message, and exit with code 130 (SIGINT) or
|
|
327
|
+
* 143 (SIGTERM).
|
|
328
|
+
*
|
|
329
|
+
* @returns A dispose function that removes the handlers
|
|
330
|
+
*/
|
|
331
|
+
declare function installSignalHandlers(): () => void;
|
|
332
|
+
|
|
333
|
+
export { type AdvanceOptions, type AdvanceResult, type IndexAddOptions, type IndexAuditOptions, type InitOptions, type PromptOptions, type StatusJson, type StatusOptions, type UpdateOptions, type UpdateResult, createProgram, dryRunGitignorePatch, dryRunMkdir, dryRunWrite, handleError, installSignalHandlers, onCleanup, run };
|