@kb-labs/commit-contracts 0.6.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.js ADDED
@@ -0,0 +1,745 @@
1
+ import { z } from 'zod';
2
+ import { defineFlags, defineEnv } from '@kb-labs/sdk';
3
+
4
+ // src/version.ts
5
+ var contractsSchemaId = "kb.plugin.contracts/1";
6
+ var contractsVersion = "1.0.0";
7
+
8
+ // src/contract.ts
9
+ var pluginContractsManifest = {
10
+ schema: contractsSchemaId,
11
+ pluginId: "@kb-labs/commit",
12
+ contractsVersion,
13
+ artifacts: {
14
+ "commit.plan.json": {
15
+ id: "commit.plan.json",
16
+ kind: "json",
17
+ description: "Current commit plan generated by LLM analysis of git changes.",
18
+ pathPattern: ".kb/commit/current/plan.json",
19
+ mediaType: "application/json",
20
+ schemaRef: "@kb-labs/commit-contracts/schema#CommitPlan",
21
+ example: {
22
+ summary: "Example commit plan with two commits",
23
+ payload: {
24
+ schemaVersion: "1.0",
25
+ commits: [
26
+ {
27
+ id: "c1",
28
+ type: "feat",
29
+ scope: "ui",
30
+ message: "add button component",
31
+ files: ["src/components/Button.tsx"],
32
+ releaseHint: "minor"
33
+ }
34
+ ]
35
+ }
36
+ }
37
+ },
38
+ "commit.status.json": {
39
+ id: "commit.status.json",
40
+ kind: "json",
41
+ description: "Git status snapshot at plan generation time.",
42
+ pathPattern: ".kb/commit/current/status.json",
43
+ mediaType: "application/json",
44
+ schemaRef: "@kb-labs/commit-contracts/schema#GitStatusSnapshot"
45
+ },
46
+ "commit.history": {
47
+ id: "commit.history",
48
+ kind: "dir",
49
+ description: "History of applied commit plans with results.",
50
+ pathPattern: ".kb/commit/history/"
51
+ }
52
+ },
53
+ commands: {
54
+ commit: {
55
+ id: "commit",
56
+ description: "Generate and apply commits (default flow).",
57
+ input: {
58
+ ref: "@kb-labs/commit-contracts/schema#CommitRunInput",
59
+ format: "zod"
60
+ },
61
+ output: {
62
+ ref: "@kb-labs/commit-contracts/schema#CommitRunOutput",
63
+ format: "zod"
64
+ },
65
+ produces: ["commit.plan.json", "commit.status.json"],
66
+ examples: ["kb commit", "kb commit --dry-run", "kb commit --with-push"]
67
+ },
68
+ "commit:generate": {
69
+ id: "commit:generate",
70
+ description: "Generate commit plan from git changes using LLM.",
71
+ input: {
72
+ ref: "@kb-labs/commit-contracts/schema#GenerateInput",
73
+ format: "zod"
74
+ },
75
+ output: {
76
+ ref: "@kb-labs/commit-contracts/schema#GenerateOutput",
77
+ format: "zod"
78
+ },
79
+ produces: ["commit.plan.json", "commit.status.json"],
80
+ examples: [
81
+ "kb commit generate",
82
+ "kb commit generate --json",
83
+ "kb commit generate --scope src/**"
84
+ ]
85
+ },
86
+ "commit:apply": {
87
+ id: "commit:apply",
88
+ description: "Apply current commit plan (create local git commits).",
89
+ input: {
90
+ ref: "@kb-labs/commit-contracts/schema#ApplyInput",
91
+ format: "zod"
92
+ },
93
+ output: {
94
+ ref: "@kb-labs/commit-contracts/schema#ApplyOutput",
95
+ format: "zod"
96
+ },
97
+ produces: [],
98
+ examples: ["kb commit apply", "kb commit apply --force"]
99
+ },
100
+ "commit:push": {
101
+ id: "commit:push",
102
+ description: "Push commits to remote repository.",
103
+ input: {
104
+ ref: "@kb-labs/commit-contracts/schema#PushInput",
105
+ format: "zod"
106
+ },
107
+ output: {
108
+ ref: "@kb-labs/commit-contracts/schema#PushOutput",
109
+ format: "zod"
110
+ },
111
+ produces: [],
112
+ examples: ["kb commit push", "kb commit push --force"]
113
+ },
114
+ "commit:open": {
115
+ id: "commit:open",
116
+ description: "Show current commit plan.",
117
+ input: {
118
+ ref: "@kb-labs/commit-contracts/schema#OpenInput",
119
+ format: "zod"
120
+ },
121
+ output: {
122
+ ref: "@kb-labs/commit-contracts/schema#OpenOutput",
123
+ format: "zod"
124
+ },
125
+ produces: [],
126
+ examples: ["kb commit open", "kb commit open --json"]
127
+ },
128
+ "commit:reset": {
129
+ id: "commit:reset",
130
+ description: "Clear current commit plan.",
131
+ output: {
132
+ ref: "@kb-labs/commit-contracts/schema#ResetOutput",
133
+ format: "zod"
134
+ },
135
+ produces: [],
136
+ examples: ["kb commit reset"]
137
+ }
138
+ }
139
+ };
140
+
141
+ // src/helpers.ts
142
+ function getArtifactPath(id) {
143
+ const artifact = pluginContractsManifest.artifacts[id];
144
+ if (!artifact) {
145
+ throw new Error(`Artifact ${String(id)} not found in contracts`);
146
+ }
147
+ return artifact.pathPattern;
148
+ }
149
+ function getArtifact(id) {
150
+ const artifact = pluginContractsManifest.artifacts[id];
151
+ if (!artifact) {
152
+ throw new Error(`Artifact ${String(id)} not found in contracts`);
153
+ }
154
+ return artifact;
155
+ }
156
+ function hasArtifact(id) {
157
+ return id in pluginContractsManifest.artifacts;
158
+ }
159
+ function getCommand(id) {
160
+ if (!pluginContractsManifest.commands) {
161
+ throw new Error("Commands not defined in contracts");
162
+ }
163
+ const command = pluginContractsManifest.commands[id];
164
+ if (!command) {
165
+ throw new Error(`Command ${String(id)} not found in contracts`);
166
+ }
167
+ return command;
168
+ }
169
+ function hasCommand(id) {
170
+ return pluginContractsManifest.commands !== void 0 && id in pluginContractsManifest.commands;
171
+ }
172
+ function getCommandId(id) {
173
+ return id;
174
+ }
175
+ function getArtifactId(id) {
176
+ return id;
177
+ }
178
+ var schemaReferenceSchema = z.object({
179
+ ref: z.string().min(1),
180
+ format: z.enum(["zod", "json-schema", "openapi"]).optional(),
181
+ description: z.string().optional()
182
+ });
183
+ var restRouteContractSchema = z.object({
184
+ id: z.string().min(1),
185
+ method: z.string().min(1),
186
+ path: z.string().min(1),
187
+ description: z.string().optional(),
188
+ request: schemaReferenceSchema.optional(),
189
+ response: schemaReferenceSchema.optional(),
190
+ produces: z.array(z.string().min(1)).optional(),
191
+ consumes: z.array(z.string().min(1)).optional()
192
+ });
193
+ var restApiContractSchema = z.object({
194
+ basePath: z.string().min(1),
195
+ routes: z.record(restRouteContractSchema)
196
+ });
197
+ var apiContractSchema = z.object({
198
+ rest: restApiContractSchema.optional()
199
+ });
200
+ var artifactExampleSchema = z.object({
201
+ summary: z.string().optional(),
202
+ payload: z.unknown().optional()
203
+ });
204
+ var artifactContractSchema = z.object({
205
+ id: z.string().min(1),
206
+ kind: z.enum(["file", "json", "markdown", "binary", "dir", "log"]),
207
+ description: z.string().optional(),
208
+ pathPattern: z.string().min(1).optional(),
209
+ mediaType: z.string().min(1).optional(),
210
+ schemaRef: z.string().min(1).optional(),
211
+ example: artifactExampleSchema.optional()
212
+ });
213
+ var artifactsContractMapSchema = z.record(artifactContractSchema);
214
+ var commandContractSchema = z.object({
215
+ id: z.string().min(1),
216
+ description: z.string().optional(),
217
+ input: schemaReferenceSchema.optional(),
218
+ output: schemaReferenceSchema.optional(),
219
+ produces: z.array(z.string().min(1)).optional(),
220
+ consumes: z.array(z.string().min(1)).optional(),
221
+ examples: z.array(z.string().min(1)).optional()
222
+ });
223
+ var commandContractMapSchema = z.record(commandContractSchema);
224
+ var workflowStepSchema = z.object({
225
+ id: z.string().min(1),
226
+ description: z.string().optional(),
227
+ commandId: z.string().min(1).optional(),
228
+ consumes: z.array(z.string().min(1)).optional(),
229
+ produces: z.array(z.string().min(1)).optional()
230
+ });
231
+ var workflowContractSchema = z.object({
232
+ id: z.string().min(1),
233
+ description: z.string().optional(),
234
+ consumes: z.array(z.string().min(1)).optional(),
235
+ produces: z.array(z.string().min(1)).optional(),
236
+ steps: z.array(workflowStepSchema).optional()
237
+ });
238
+ var workflowContractMapSchema = z.record(workflowContractSchema);
239
+
240
+ // src/schema/contract.schema.ts
241
+ var pluginContractsSchema = z.object({
242
+ schema: z.literal(contractsSchemaId),
243
+ pluginId: z.string().min(1),
244
+ contractsVersion: z.string().min(1),
245
+ artifacts: artifactsContractMapSchema,
246
+ commands: commandContractMapSchema.optional(),
247
+ workflows: workflowContractMapSchema.optional(),
248
+ api: apiContractSchema.optional()
249
+ }).strict();
250
+ function parsePluginContracts(input) {
251
+ return pluginContractsSchema.parse(input);
252
+ }
253
+
254
+ // src/types/config.ts
255
+ var COMMIT_ENV_VARS = [
256
+ "KB_COMMIT_LLM_ENABLED",
257
+ "KB_COMMIT_LLM_TEMPERATURE",
258
+ "KB_COMMIT_LLM_MAX_TOKENS",
259
+ "KB_COMMIT_STORAGE_DIR",
260
+ "KB_COMMIT_AUTO_STAGE"
261
+ ];
262
+ var defaultCommitConfig = {
263
+ enabled: true,
264
+ llm: {
265
+ enabled: true,
266
+ temperature: 0.3,
267
+ maxTokens: 2e3
268
+ },
269
+ storage: {
270
+ directory: ".kb/commit"
271
+ },
272
+ git: {
273
+ protectedBranches: ["main", "master"],
274
+ autoStage: false
275
+ },
276
+ scope: {
277
+ default: "root",
278
+ scopes: [{ id: "root", label: "root", path: "." }]
279
+ }
280
+ };
281
+ function resolveCommitConfig(fileConfig = {}, env = {}) {
282
+ const config = {
283
+ enabled: fileConfig.enabled ?? defaultCommitConfig.enabled,
284
+ llm: {
285
+ enabled: env.KB_COMMIT_LLM_ENABLED ?? fileConfig.llm?.enabled ?? defaultCommitConfig.llm.enabled,
286
+ temperature: env.KB_COMMIT_LLM_TEMPERATURE ?? fileConfig.llm?.temperature ?? defaultCommitConfig.llm.temperature,
287
+ maxTokens: env.KB_COMMIT_LLM_MAX_TOKENS ?? fileConfig.llm?.maxTokens ?? defaultCommitConfig.llm.maxTokens
288
+ },
289
+ storage: {
290
+ directory: env.KB_COMMIT_STORAGE_DIR ?? fileConfig.storage?.directory ?? defaultCommitConfig.storage.directory
291
+ },
292
+ git: {
293
+ protectedBranches: fileConfig.git?.protectedBranches ?? defaultCommitConfig.git.protectedBranches,
294
+ autoStage: env.KB_COMMIT_AUTO_STAGE ?? fileConfig.git?.autoStage ?? defaultCommitConfig.git.autoStage
295
+ },
296
+ scope: {
297
+ default: fileConfig.scope?.default ?? defaultCommitConfig.scope?.default,
298
+ scopes: fileConfig.scope?.scopes ?? defaultCommitConfig.scope?.scopes
299
+ }
300
+ };
301
+ return config;
302
+ }
303
+ var ConventionalTypeSchema = z.enum([
304
+ "feat",
305
+ "fix",
306
+ "refactor",
307
+ "chore",
308
+ "docs",
309
+ "test",
310
+ "build",
311
+ "ci",
312
+ "perf"
313
+ ]);
314
+ var ReleaseHintSchema = z.enum(["none", "patch", "minor", "major"]);
315
+ var GitStatusSchema = z.object({
316
+ staged: z.array(z.string()),
317
+ unstaged: z.array(z.string()),
318
+ untracked: z.array(z.string())
319
+ });
320
+ var FileSummarySchema = z.object({
321
+ path: z.string(),
322
+ status: z.enum(["added", "modified", "deleted", "renamed", "copied"]),
323
+ additions: z.number().int().min(0),
324
+ deletions: z.number().int().min(0),
325
+ binary: z.boolean().default(false),
326
+ /** Whether file is truly new (never existed in repo history) */
327
+ isNewFile: z.boolean().default(false)
328
+ });
329
+ var CommitReasoningSchema = z.object({
330
+ /** Does this change add NEW user-visible behavior? */
331
+ newBehavior: z.boolean().default(false),
332
+ /** Does this change fix BROKEN functionality? */
333
+ fixesBug: z.boolean().default(false),
334
+ /** Is this only INTERNAL restructuring? */
335
+ internalOnly: z.boolean().default(false),
336
+ /** Human-readable explanation of why this type was chosen */
337
+ explanation: z.string().default(""),
338
+ /** LLM confidence in this classification (0.0-1.0) */
339
+ confidence: z.number().min(0).max(1).default(0.5)
340
+ });
341
+ var CommitGroupSchema = z.object({
342
+ id: z.string(),
343
+ type: ConventionalTypeSchema,
344
+ scope: z.string().optional(),
345
+ message: z.string().min(1),
346
+ body: z.string().optional(),
347
+ files: z.array(z.string()).min(1),
348
+ releaseHint: ReleaseHintSchema.default("none"),
349
+ breaking: z.boolean().default(false),
350
+ /** Reasoning for commit type classification (optional, added by LLM) */
351
+ reasoning: CommitReasoningSchema.optional()
352
+ });
353
+ var CommitPlanSchema = z.object({
354
+ schemaVersion: z.literal("1.0"),
355
+ createdAt: z.string().datetime(),
356
+ repoRoot: z.string(),
357
+ gitStatus: GitStatusSchema,
358
+ commits: z.array(CommitGroupSchema),
359
+ metadata: z.object({
360
+ totalFiles: z.number().int().min(0),
361
+ totalCommits: z.number().int().min(0),
362
+ llmUsed: z.boolean(),
363
+ tokensUsed: z.number().int().min(0).optional(),
364
+ /** Whether LLM escalated to Phase 2 (requested diff for more context) */
365
+ escalated: z.boolean().optional()
366
+ })
367
+ });
368
+ var GitStatusSnapshotSchema = z.object({
369
+ schemaVersion: z.literal("1.0"),
370
+ createdAt: z.string().datetime(),
371
+ status: GitStatusSchema,
372
+ summaries: z.array(FileSummarySchema)
373
+ });
374
+ var CommitRunInputSchema = z.object({
375
+ scope: z.string().optional(),
376
+ dryRun: z.boolean().default(false),
377
+ withPush: z.boolean().default(false)
378
+ });
379
+ var CommitRunOutputSchema = z.object({
380
+ plan: CommitPlanSchema,
381
+ applied: z.boolean(),
382
+ pushed: z.boolean(),
383
+ commits: z.array(
384
+ z.object({
385
+ id: z.string(),
386
+ sha: z.string().optional(),
387
+ message: z.string()
388
+ })
389
+ )
390
+ });
391
+ var GenerateInputSchema = z.object({
392
+ scope: z.string().optional()
393
+ });
394
+ var GenerateOutputSchema = z.object({
395
+ plan: CommitPlanSchema,
396
+ planPath: z.string()
397
+ });
398
+ var ApplyInputSchema = z.object({
399
+ force: z.boolean().default(false)
400
+ });
401
+ var ApplyOutputSchema = z.object({
402
+ success: z.boolean(),
403
+ commits: z.array(
404
+ z.object({
405
+ id: z.string(),
406
+ sha: z.string(),
407
+ message: z.string()
408
+ })
409
+ ),
410
+ errors: z.array(z.string()).default([])
411
+ });
412
+ var PushInputSchema = z.object({
413
+ force: z.boolean().default(false)
414
+ });
415
+ var PushOutputSchema = z.object({
416
+ success: z.boolean(),
417
+ remote: z.string(),
418
+ branch: z.string(),
419
+ commits: z.number().int().min(0)
420
+ });
421
+ var OpenInputSchema = z.object({
422
+ json: z.boolean().default(false)
423
+ });
424
+ var OpenOutputSchema = z.object({
425
+ hasPlan: z.boolean(),
426
+ plan: CommitPlanSchema.optional(),
427
+ planPath: z.string().optional()
428
+ });
429
+ var ResetOutputSchema = z.object({
430
+ success: z.boolean(),
431
+ message: z.string()
432
+ });
433
+ var ApplyResultSchema = z.object({
434
+ success: z.boolean(),
435
+ appliedCommits: z.array(
436
+ z.object({
437
+ groupId: z.string(),
438
+ sha: z.string(),
439
+ message: z.string()
440
+ })
441
+ ),
442
+ errors: z.array(z.string())
443
+ });
444
+ var PushResultSchema = z.object({
445
+ success: z.boolean(),
446
+ remote: z.string(),
447
+ branch: z.string(),
448
+ commitsPushed: z.number().int().min(0),
449
+ error: z.string().optional()
450
+ });
451
+ var ActionsResponseSchema = z.object({
452
+ scope: z.string().optional()
453
+ });
454
+ var ScopeSchema = z.object({
455
+ id: z.string().min(1),
456
+ name: z.string().min(1),
457
+ path: z.string().min(1),
458
+ description: z.string().optional()
459
+ });
460
+ var ScopesResponseSchema = z.object({
461
+ scopes: z.array(ScopeSchema)
462
+ });
463
+ var PlanStatusSchema = z.enum(["idle", "ready", "applied", "pushed"]);
464
+ var StatusResponseSchema = z.object({
465
+ scope: z.string().default("root"),
466
+ hasPlan: z.boolean(),
467
+ planStatus: PlanStatusSchema.default("idle"),
468
+ planTimestamp: z.string().datetime().optional(),
469
+ gitStatus: GitStatusSchema.optional(),
470
+ filesChanged: z.number().int().min(0).default(0),
471
+ commitsInPlan: z.number().int().min(0).default(0),
472
+ commitsApplied: z.number().int().min(0).default(0)
473
+ });
474
+ var GenerateRequestSchema = z.object({
475
+ scope: z.string().default("root"),
476
+ dryRun: z.boolean().default(false),
477
+ allowSecrets: z.boolean().default(false),
478
+ autoConfirm: z.boolean().default(false)
479
+ });
480
+ var SecretMatchSchema = z.object({
481
+ file: z.string(),
482
+ line: z.number(),
483
+ column: z.number(),
484
+ type: z.string(),
485
+ pattern: z.string(),
486
+ matched: z.string(),
487
+ context: z.string()
488
+ });
489
+ var GenerateResponseSchema = z.object({
490
+ success: z.boolean(),
491
+ // Success fields (when success=true)
492
+ plan: CommitPlanSchema.optional(),
493
+ planPath: z.string().optional(),
494
+ scope: z.string().default("root"),
495
+ // Secrets detected fields (when success=false)
496
+ secretsDetected: z.boolean().default(false),
497
+ secrets: z.array(SecretMatchSchema).optional(),
498
+ message: z.string().optional()
499
+ });
500
+ var PlanResponseSchema = z.object({
501
+ hasPlan: z.boolean(),
502
+ plan: CommitPlanSchema.optional(),
503
+ scope: z.string().default("root")
504
+ });
505
+ var PatchPlanRequestSchema = z.object({
506
+ scope: z.string().default("root"),
507
+ commitId: z.string().min(1),
508
+ message: z.string().min(1).optional(),
509
+ type: z.string().optional(),
510
+ scope_: z.string().optional(),
511
+ body: z.string().optional()
512
+ });
513
+ var PatchPlanResponseSchema = z.object({
514
+ success: z.boolean(),
515
+ scope: z.string().default("root"),
516
+ commitId: z.string()
517
+ });
518
+ var RegenerateCommitRequestSchema = z.object({
519
+ scope: z.string().default("root"),
520
+ commitId: z.string().min(1),
521
+ instruction: z.string().optional()
522
+ });
523
+ var RegenerateCommitResponseSchema = z.object({
524
+ success: z.boolean(),
525
+ scope: z.string().default("root"),
526
+ commitId: z.string(),
527
+ commit: CommitPlanSchema.shape.commits.element.optional()
528
+ });
529
+ var ApplyRequestSchema = z.object({
530
+ scope: z.string().default("root"),
531
+ force: z.boolean().default(false),
532
+ /** Optional: apply only specific commits by ID. If omitted, applies all. */
533
+ commitIds: z.array(z.string()).optional()
534
+ });
535
+ var ApplyResponseSchema = z.object({
536
+ result: ApplyResultSchema,
537
+ scope: z.string().default("root")
538
+ });
539
+ var PushRequestSchema = z.object({
540
+ scope: z.string().default("root"),
541
+ remote: z.string().default("origin"),
542
+ force: z.boolean().default(false)
543
+ });
544
+ var PushResponseSchema = z.object({
545
+ result: PushResultSchema,
546
+ scope: z.string().default("root")
547
+ });
548
+ var ResetResponseSchema = z.object({
549
+ success: z.boolean(),
550
+ message: z.string(),
551
+ scope: z.string().default("root")
552
+ });
553
+ var GitStatusResponseSchema = z.object({
554
+ scope: z.string().default("root"),
555
+ status: GitStatusSchema,
556
+ summaries: z.array(FileSummarySchema),
557
+ totalFiles: z.number().int().min(0)
558
+ });
559
+ var FileDiffResponseSchema = z.object({
560
+ scope: z.string().default("root"),
561
+ file: z.string(),
562
+ diff: z.string(),
563
+ additions: z.number().int().min(0).default(0),
564
+ deletions: z.number().int().min(0).default(0)
565
+ });
566
+ var SummarizeRequestSchema = z.object({
567
+ scope: z.string().default("root"),
568
+ /** Optional file path - if provided, summarize only this file */
569
+ file: z.string().optional()
570
+ });
571
+ var SummarizeResponseSchema = z.object({
572
+ scope: z.string().default("root"),
573
+ file: z.string().optional(),
574
+ summary: z.string(),
575
+ /** Token usage for the LLM call */
576
+ tokensUsed: z.number().int().min(0).optional()
577
+ });
578
+ var commitFlags = defineFlags({
579
+ scope: {
580
+ type: "string",
581
+ description: "Limit commits to specific package or path pattern",
582
+ examples: ["@kb-labs/core", "packages/**", "kb-labs-mind/**"]
583
+ },
584
+ json: {
585
+ type: "boolean",
586
+ description: "Output result as JSON instead of formatted text",
587
+ default: false
588
+ },
589
+ "dry-run": {
590
+ type: "boolean",
591
+ description: "Preview commits without applying them to git",
592
+ default: false
593
+ },
594
+ "with-push": {
595
+ type: "boolean",
596
+ description: "Push commits to remote after applying",
597
+ default: false
598
+ },
599
+ "allow-secrets": {
600
+ type: "boolean",
601
+ description: "Allow committing files with detected secrets (requires manual confirmation). Use with caution after reviewing detected locations.",
602
+ default: false
603
+ },
604
+ yes: {
605
+ type: "boolean",
606
+ description: "Automatically confirm all prompts (non-interactive mode)",
607
+ default: false
608
+ }
609
+ });
610
+ var generateFlags = defineFlags({
611
+ scope: {
612
+ type: "string",
613
+ description: "Limit analysis to specific package or path pattern",
614
+ examples: ["@kb-labs/core", "packages/**", "kb-labs-mind/**"]
615
+ },
616
+ json: {
617
+ type: "boolean",
618
+ description: "Output commit plan as JSON instead of formatted text",
619
+ default: false
620
+ },
621
+ "allow-secrets": {
622
+ type: "boolean",
623
+ description: "Allow generating commits for files with detected secrets (requires manual confirmation). Use with caution after reviewing detected locations.",
624
+ default: false
625
+ },
626
+ yes: {
627
+ type: "boolean",
628
+ description: "Automatically confirm all prompts (non-interactive mode)",
629
+ default: false
630
+ }
631
+ });
632
+ var commitEnv = defineEnv({
633
+ KB_COMMIT_LLM_ENABLED: {
634
+ type: "boolean",
635
+ default: true,
636
+ description: "Enable LLM-powered commit analysis"
637
+ },
638
+ KB_COMMIT_LLM_TEMPERATURE: {
639
+ type: "number",
640
+ default: 0.3,
641
+ description: "LLM temperature for commit message generation (0-1)",
642
+ validate: (v) => {
643
+ if (v < 0 || v > 1) {
644
+ throw new Error("KB_COMMIT_LLM_TEMPERATURE must be between 0 and 1");
645
+ }
646
+ }
647
+ },
648
+ KB_COMMIT_LLM_MAX_TOKENS: {
649
+ type: "number",
650
+ default: 2e3,
651
+ description: "Maximum tokens for LLM commit analysis"
652
+ },
653
+ KB_COMMIT_STORAGE_DIR: {
654
+ type: "string",
655
+ default: ".kb/commit",
656
+ description: "Directory for storing commit history"
657
+ },
658
+ KB_COMMIT_AUTO_STAGE: {
659
+ type: "boolean",
660
+ default: false,
661
+ description: "Automatically stage files before committing"
662
+ }
663
+ });
664
+
665
+ // src/routes.ts
666
+ var COMMIT_BASE_PATH = "/v1/plugins/commit";
667
+ var COMMIT_ROUTES = {
668
+ /** GET /scopes - List available scopes */
669
+ SCOPES: "/scopes",
670
+ /** GET /status - Get current status (plan + git) */
671
+ STATUS: "/status",
672
+ /** GET /plan - Get current commit plan */
673
+ PLAN: "/plan",
674
+ /** GET /git-status - Get git status with file details */
675
+ GIT_STATUS: "/git-status",
676
+ /** GET /files - Get file tree with diff statistics */
677
+ FILES: "/files",
678
+ /** GET /diff - Get diff for a specific file */
679
+ DIFF: "/diff",
680
+ /** POST /summarize - Summarize changes using LLM */
681
+ SUMMARIZE: "/summarize",
682
+ /** GET /actions - Get actions widget data */
683
+ ACTIONS: "/actions",
684
+ /** POST /generate - Generate new commit plan */
685
+ GENERATE: "/generate",
686
+ /** POST /apply - Apply commit plan */
687
+ APPLY: "/apply",
688
+ /** POST /push - Push commits to remote */
689
+ PUSH: "/push",
690
+ /** DELETE /plan - Delete current plan */
691
+ RESET: "/plan",
692
+ /** PATCH /plan - Edit a single commit in the plan */
693
+ PATCH_PLAN: "/plan",
694
+ /** POST /regenerate-commit - Regenerate a single commit */
695
+ REGENERATE_COMMIT: "/regenerate-commit"
696
+ };
697
+ var COMMIT_FULL_ROUTES = {
698
+ SCOPES: `${COMMIT_BASE_PATH}${COMMIT_ROUTES.SCOPES}`,
699
+ STATUS: `${COMMIT_BASE_PATH}${COMMIT_ROUTES.STATUS}`,
700
+ PLAN: `${COMMIT_BASE_PATH}${COMMIT_ROUTES.PLAN}`,
701
+ GIT_STATUS: `${COMMIT_BASE_PATH}${COMMIT_ROUTES.GIT_STATUS}`,
702
+ FILES: `${COMMIT_BASE_PATH}${COMMIT_ROUTES.FILES}`,
703
+ DIFF: `${COMMIT_BASE_PATH}${COMMIT_ROUTES.DIFF}`,
704
+ SUMMARIZE: `${COMMIT_BASE_PATH}${COMMIT_ROUTES.SUMMARIZE}`,
705
+ ACTIONS: `${COMMIT_BASE_PATH}${COMMIT_ROUTES.ACTIONS}`,
706
+ GENERATE: `${COMMIT_BASE_PATH}${COMMIT_ROUTES.GENERATE}`,
707
+ APPLY: `${COMMIT_BASE_PATH}${COMMIT_ROUTES.APPLY}`,
708
+ PUSH: `${COMMIT_BASE_PATH}${COMMIT_ROUTES.PUSH}`,
709
+ RESET: `${COMMIT_BASE_PATH}${COMMIT_ROUTES.RESET}`,
710
+ PATCH_PLAN: `${COMMIT_BASE_PATH}${COMMIT_ROUTES.PATCH_PLAN}`,
711
+ REGENERATE_COMMIT: `${COMMIT_BASE_PATH}${COMMIT_ROUTES.REGENERATE_COMMIT}`
712
+ };
713
+ var COMMIT_WIDGET_ROUTES = {
714
+ SCOPES: "scopes",
715
+ STATUS: "status",
716
+ PLAN: "plan",
717
+ GIT_STATUS: "git-status",
718
+ FILES: "files",
719
+ DIFF: "diff",
720
+ SUMMARIZE: "summarize",
721
+ ACTIONS: "actions",
722
+ GENERATE: "generate",
723
+ APPLY: "apply",
724
+ PUSH: "push",
725
+ RESET: "plan",
726
+ PATCH_PLAN: "plan",
727
+ REGENERATE_COMMIT: "regenerate-commit"
728
+ };
729
+
730
+ // src/events.ts
731
+ var COMMIT_EVENTS = {
732
+ /** Scope selector changed */
733
+ SCOPE_CHANGED: "scope:changed",
734
+ /** Form submitted (actions widget) */
735
+ FORM_SUBMITTED: "form:submitted",
736
+ /** Commit plan generated */
737
+ PLAN_GENERATED: "plan:generated"
738
+ };
739
+
740
+ // src/index.ts
741
+ var COMMIT_CACHE_PREFIX = "commit:";
742
+
743
+ export { ActionsResponseSchema, ApplyInputSchema, ApplyOutputSchema, ApplyRequestSchema, ApplyResponseSchema, ApplyResultSchema, COMMIT_BASE_PATH, COMMIT_CACHE_PREFIX, COMMIT_ENV_VARS, COMMIT_EVENTS, COMMIT_FULL_ROUTES, COMMIT_ROUTES, COMMIT_WIDGET_ROUTES, CommitGroupSchema, CommitPlanSchema, CommitReasoningSchema, CommitRunInputSchema, CommitRunOutputSchema, ConventionalTypeSchema, FileDiffResponseSchema, FileSummarySchema, GenerateInputSchema, GenerateOutputSchema, GenerateRequestSchema, GenerateResponseSchema, GitStatusResponseSchema, GitStatusSchema, GitStatusSnapshotSchema, OpenInputSchema, OpenOutputSchema, PatchPlanRequestSchema, PatchPlanResponseSchema, PlanResponseSchema, PlanStatusSchema, PushInputSchema, PushOutputSchema, PushRequestSchema, PushResponseSchema, PushResultSchema, RegenerateCommitRequestSchema, RegenerateCommitResponseSchema, ReleaseHintSchema, ResetOutputSchema, ResetResponseSchema, ScopeSchema, ScopesResponseSchema, SecretMatchSchema, StatusResponseSchema, SummarizeRequestSchema, SummarizeResponseSchema, commitEnv, commitFlags, contractsSchemaId, contractsVersion, defaultCommitConfig, generateFlags, getArtifact, getArtifactId, getArtifactPath, getCommand, getCommandId, hasArtifact, hasCommand, parsePluginContracts, pluginContractsManifest, pluginContractsSchema, resolveCommitConfig };
744
+ //# sourceMappingURL=index.js.map
745
+ //# sourceMappingURL=index.js.map