agkan 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/README.ja.md +1127 -0
- package/README.md +1140 -0
- package/bin/agkan +2 -0
- package/dist/cli/commands/block/add.d.ts +6 -0
- package/dist/cli/commands/block/add.d.ts.map +1 -0
- package/dist/cli/commands/block/add.js +135 -0
- package/dist/cli/commands/block/add.js.map +1 -0
- package/dist/cli/commands/block/list.d.ts +6 -0
- package/dist/cli/commands/block/list.d.ts.map +1 -0
- package/dist/cli/commands/block/list.js +120 -0
- package/dist/cli/commands/block/list.js.map +1 -0
- package/dist/cli/commands/block/remove.d.ts +6 -0
- package/dist/cli/commands/block/remove.d.ts.map +1 -0
- package/dist/cli/commands/block/remove.js +117 -0
- package/dist/cli/commands/block/remove.js.map +1 -0
- package/dist/cli/commands/meta/delete.d.ts +6 -0
- package/dist/cli/commands/meta/delete.d.ts.map +1 -0
- package/dist/cli/commands/meta/delete.js +67 -0
- package/dist/cli/commands/meta/delete.js.map +1 -0
- package/dist/cli/commands/meta/get.d.ts +6 -0
- package/dist/cli/commands/meta/get.d.ts.map +1 -0
- package/dist/cli/commands/meta/get.js +71 -0
- package/dist/cli/commands/meta/get.js.map +1 -0
- package/dist/cli/commands/meta/list.d.ts +6 -0
- package/dist/cli/commands/meta/list.d.ts.map +1 -0
- package/dist/cli/commands/meta/list.js +69 -0
- package/dist/cli/commands/meta/list.js.map +1 -0
- package/dist/cli/commands/meta/set.d.ts +6 -0
- package/dist/cli/commands/meta/set.d.ts.map +1 -0
- package/dist/cli/commands/meta/set.js +85 -0
- package/dist/cli/commands/meta/set.js.map +1 -0
- package/dist/cli/commands/tag/add.d.ts +6 -0
- package/dist/cli/commands/tag/add.d.ts.map +1 -0
- package/dist/cli/commands/tag/add.js +99 -0
- package/dist/cli/commands/tag/add.js.map +1 -0
- package/dist/cli/commands/tag/attach.d.ts +6 -0
- package/dist/cli/commands/tag/attach.d.ts.map +1 -0
- package/dist/cli/commands/tag/attach.js +119 -0
- package/dist/cli/commands/tag/attach.js.map +1 -0
- package/dist/cli/commands/tag/delete.d.ts +6 -0
- package/dist/cli/commands/tag/delete.d.ts.map +1 -0
- package/dist/cli/commands/tag/delete.js +93 -0
- package/dist/cli/commands/tag/delete.js.map +1 -0
- package/dist/cli/commands/tag/detach.d.ts +6 -0
- package/dist/cli/commands/tag/detach.d.ts.map +1 -0
- package/dist/cli/commands/tag/detach.js +118 -0
- package/dist/cli/commands/tag/detach.js.map +1 -0
- package/dist/cli/commands/tag/list.d.ts +6 -0
- package/dist/cli/commands/tag/list.d.ts.map +1 -0
- package/dist/cli/commands/tag/list.js +80 -0
- package/dist/cli/commands/tag/list.js.map +1 -0
- package/dist/cli/commands/tag/show.d.ts +6 -0
- package/dist/cli/commands/tag/show.d.ts.map +1 -0
- package/dist/cli/commands/tag/show.js +88 -0
- package/dist/cli/commands/tag/show.js.map +1 -0
- package/dist/cli/commands/task/add-helpers.d.ts +17 -0
- package/dist/cli/commands/task/add-helpers.d.ts.map +1 -0
- package/dist/cli/commands/task/add-helpers.js +122 -0
- package/dist/cli/commands/task/add-helpers.js.map +1 -0
- package/dist/cli/commands/task/add.d.ts +6 -0
- package/dist/cli/commands/task/add.d.ts.map +1 -0
- package/dist/cli/commands/task/add.js +140 -0
- package/dist/cli/commands/task/add.js.map +1 -0
- package/dist/cli/commands/task/count.d.ts +6 -0
- package/dist/cli/commands/task/count.d.ts.map +1 -0
- package/dist/cli/commands/task/count.js +97 -0
- package/dist/cli/commands/task/count.js.map +1 -0
- package/dist/cli/commands/task/delete.d.ts +6 -0
- package/dist/cli/commands/task/delete.d.ts.map +1 -0
- package/dist/cli/commands/task/delete.js +59 -0
- package/dist/cli/commands/task/delete.js.map +1 -0
- package/dist/cli/commands/task/find.d.ts +7 -0
- package/dist/cli/commands/task/find.d.ts.map +1 -0
- package/dist/cli/commands/task/find.js +118 -0
- package/dist/cli/commands/task/find.js.map +1 -0
- package/dist/cli/commands/task/get.d.ts +6 -0
- package/dist/cli/commands/task/get.d.ts.map +1 -0
- package/dist/cli/commands/task/get.js +196 -0
- package/dist/cli/commands/task/get.js.map +1 -0
- package/dist/cli/commands/task/list.d.ts +6 -0
- package/dist/cli/commands/task/list.d.ts.map +1 -0
- package/dist/cli/commands/task/list.js +301 -0
- package/dist/cli/commands/task/list.js.map +1 -0
- package/dist/cli/commands/task/update-parent.d.ts +6 -0
- package/dist/cli/commands/task/update-parent.d.ts.map +1 -0
- package/dist/cli/commands/task/update-parent.js +123 -0
- package/dist/cli/commands/task/update-parent.js.map +1 -0
- package/dist/cli/commands/task/update.d.ts +6 -0
- package/dist/cli/commands/task/update.d.ts.map +1 -0
- package/dist/cli/commands/task/update.js +96 -0
- package/dist/cli/commands/task/update.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +68 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/utils/array-utils.d.ts +15 -0
- package/dist/cli/utils/array-utils.d.ts.map +1 -0
- package/dist/cli/utils/array-utils.js +20 -0
- package/dist/cli/utils/array-utils.js.map +1 -0
- package/dist/cli/utils/error-handler.d.ts +35 -0
- package/dist/cli/utils/error-handler.d.ts.map +1 -0
- package/dist/cli/utils/error-handler.js +84 -0
- package/dist/cli/utils/error-handler.js.map +1 -0
- package/dist/cli/utils/output-formatter.d.ts +34 -0
- package/dist/cli/utils/output-formatter.d.ts.map +1 -0
- package/dist/cli/utils/output-formatter.js +44 -0
- package/dist/cli/utils/output-formatter.js.map +1 -0
- package/dist/cli/utils/response-formatter.d.ts +19 -0
- package/dist/cli/utils/response-formatter.d.ts.map +1 -0
- package/dist/cli/utils/response-formatter.js +43 -0
- package/dist/cli/utils/response-formatter.js.map +1 -0
- package/dist/cli/utils/validators.d.ts +23 -0
- package/dist/cli/utils/validators.d.ts.map +1 -0
- package/dist/cli/utils/validators.js +47 -0
- package/dist/cli/utils/validators.js.map +1 -0
- package/dist/db/config.d.ts +27 -0
- package/dist/db/config.d.ts.map +1 -0
- package/dist/db/config.js +116 -0
- package/dist/db/config.js.map +1 -0
- package/dist/db/connection.d.ts +24 -0
- package/dist/db/connection.d.ts.map +1 -0
- package/dist/db/connection.js +62 -0
- package/dist/db/connection.js.map +1 -0
- package/dist/db/reset.d.ts +8 -0
- package/dist/db/reset.d.ts.map +1 -0
- package/dist/db/reset.js +33 -0
- package/dist/db/reset.js.map +1 -0
- package/dist/db/schema.d.ts +6 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +134 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/models/Attachment.d.ts +25 -0
- package/dist/models/Attachment.d.ts.map +1 -0
- package/dist/models/Attachment.js +7 -0
- package/dist/models/Attachment.js.map +1 -0
- package/dist/models/Tag.d.ts +24 -0
- package/dist/models/Tag.d.ts.map +1 -0
- package/dist/models/Tag.js +3 -0
- package/dist/models/Tag.js.map +1 -0
- package/dist/models/Task.d.ts +55 -0
- package/dist/models/Task.d.ts.map +1 -0
- package/dist/models/Task.js +7 -0
- package/dist/models/Task.js.map +1 -0
- package/dist/models/TaskBlock.d.ts +11 -0
- package/dist/models/TaskBlock.d.ts.map +1 -0
- package/dist/models/TaskBlock.js +3 -0
- package/dist/models/TaskBlock.js.map +1 -0
- package/dist/models/TaskMetadata.d.ts +30 -0
- package/dist/models/TaskMetadata.d.ts.map +1 -0
- package/dist/models/TaskMetadata.js +3 -0
- package/dist/models/TaskMetadata.js.map +1 -0
- package/dist/models/TaskTag.d.ts +11 -0
- package/dist/models/TaskTag.d.ts.map +1 -0
- package/dist/models/TaskTag.js +3 -0
- package/dist/models/TaskTag.js.map +1 -0
- package/dist/models/index.d.ts +10 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +7 -0
- package/dist/models/index.js.map +1 -0
- package/dist/services/AttachmentService.d.ts +62 -0
- package/dist/services/AttachmentService.d.ts.map +1 -0
- package/dist/services/AttachmentService.js +95 -0
- package/dist/services/AttachmentService.js.map +1 -0
- package/dist/services/FileService.d.ts +31 -0
- package/dist/services/FileService.d.ts.map +1 -0
- package/dist/services/FileService.js +77 -0
- package/dist/services/FileService.js.map +1 -0
- package/dist/services/MetadataService.d.ts +49 -0
- package/dist/services/MetadataService.d.ts.map +1 -0
- package/dist/services/MetadataService.js +126 -0
- package/dist/services/MetadataService.js.map +1 -0
- package/dist/services/TagService.d.ts +49 -0
- package/dist/services/TagService.d.ts.map +1 -0
- package/dist/services/TagService.js +127 -0
- package/dist/services/TagService.js.map +1 -0
- package/dist/services/TaskBlockService.d.ts +49 -0
- package/dist/services/TaskBlockService.d.ts.map +1 -0
- package/dist/services/TaskBlockService.js +118 -0
- package/dist/services/TaskBlockService.js.map +1 -0
- package/dist/services/TaskService.d.ts +89 -0
- package/dist/services/TaskService.d.ts.map +1 -0
- package/dist/services/TaskService.js +285 -0
- package/dist/services/TaskService.js.map +1 -0
- package/dist/services/TaskTagService.d.ts +66 -0
- package/dist/services/TaskTagService.d.ts.map +1 -0
- package/dist/services/TaskTagService.js +171 -0
- package/dist/services/TaskTagService.js.map +1 -0
- package/dist/services/index.d.ts +11 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +20 -0
- package/dist/services/index.js.map +1 -0
- package/dist/utils/cycle-detector.d.ts +14 -0
- package/dist/utils/cycle-detector.d.ts.map +1 -0
- package/dist/utils/cycle-detector.js +32 -0
- package/dist/utils/cycle-detector.js.map +1 -0
- package/dist/utils/format.d.ts +13 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +29 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/input-validators.d.ts +32 -0
- package/dist/utils/input-validators.d.ts.map +1 -0
- package/dist/utils/input-validators.js +108 -0
- package/dist/utils/input-validators.js.map +1 -0
- package/dist/utils/security.d.ts +11 -0
- package/dist/utils/security.d.ts.map +1 -0
- package/dist/utils/security.js +29 -0
- package/dist/utils/security.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
// Task command handlers
|
|
8
|
+
const add_1 = require("./commands/task/add");
|
|
9
|
+
const list_1 = require("./commands/task/list");
|
|
10
|
+
const get_1 = require("./commands/task/get");
|
|
11
|
+
const update_1 = require("./commands/task/update");
|
|
12
|
+
const find_1 = require("./commands/task/find");
|
|
13
|
+
const count_1 = require("./commands/task/count");
|
|
14
|
+
const update_parent_1 = require("./commands/task/update-parent");
|
|
15
|
+
const delete_1 = require("./commands/task/delete");
|
|
16
|
+
// Block command handlers
|
|
17
|
+
const add_2 = require("./commands/block/add");
|
|
18
|
+
const remove_1 = require("./commands/block/remove");
|
|
19
|
+
const list_2 = require("./commands/block/list");
|
|
20
|
+
// Tag command handlers
|
|
21
|
+
const add_3 = require("./commands/tag/add");
|
|
22
|
+
const list_3 = require("./commands/tag/list");
|
|
23
|
+
const delete_2 = require("./commands/tag/delete");
|
|
24
|
+
const attach_1 = require("./commands/tag/attach");
|
|
25
|
+
const detach_1 = require("./commands/tag/detach");
|
|
26
|
+
const show_1 = require("./commands/tag/show");
|
|
27
|
+
// Meta command handlers
|
|
28
|
+
const set_1 = require("./commands/meta/set");
|
|
29
|
+
const get_2 = require("./commands/meta/get");
|
|
30
|
+
const list_4 = require("./commands/meta/list");
|
|
31
|
+
const delete_3 = require("./commands/meta/delete");
|
|
32
|
+
const program = new commander_1.Command();
|
|
33
|
+
// Load version from package.json
|
|
34
|
+
const packageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../../package.json'), 'utf8'));
|
|
35
|
+
// Program basic information
|
|
36
|
+
program.name('agkan').version(packageJson.version).description('TypeScript-based CLI task management tool');
|
|
37
|
+
// Create task command group
|
|
38
|
+
program.command('task').description('Task management commands');
|
|
39
|
+
// Register task commands
|
|
40
|
+
(0, add_1.setupTaskAddCommand)(program);
|
|
41
|
+
(0, list_1.setupTaskListCommand)(program);
|
|
42
|
+
(0, get_1.setupTaskGetCommand)(program);
|
|
43
|
+
(0, update_1.setupTaskUpdateCommand)(program);
|
|
44
|
+
(0, find_1.setupTaskFindCommand)(program);
|
|
45
|
+
(0, count_1.setupTaskCountCommand)(program);
|
|
46
|
+
(0, update_parent_1.setupTaskUpdateParentCommand)(program);
|
|
47
|
+
(0, delete_1.setupTaskDeleteCommand)(program);
|
|
48
|
+
// Register block commands (block and tag handlers create their own subcommands)
|
|
49
|
+
(0, add_2.setupBlockAddCommand)(program);
|
|
50
|
+
(0, remove_1.setupBlockRemoveCommand)(program);
|
|
51
|
+
(0, list_2.setupBlockListCommand)(program);
|
|
52
|
+
// Create tag command group
|
|
53
|
+
program.command('tag').description('Tag management commands');
|
|
54
|
+
// Register tag commands
|
|
55
|
+
(0, add_3.setupTagAddCommand)(program);
|
|
56
|
+
(0, list_3.setupTagListCommand)(program);
|
|
57
|
+
(0, delete_2.setupTagDeleteCommand)(program);
|
|
58
|
+
(0, attach_1.setupTagAttachCommand)(program);
|
|
59
|
+
(0, detach_1.setupTagDetachCommand)(program);
|
|
60
|
+
(0, show_1.setupTagShowCommand)(program);
|
|
61
|
+
// Register meta commands
|
|
62
|
+
(0, set_1.setupMetaSetCommand)(program);
|
|
63
|
+
(0, get_2.setupMetaGetCommand)(program);
|
|
64
|
+
(0, list_4.setupMetaListCommand)(program);
|
|
65
|
+
(0, delete_3.setupMetaDeleteCommand)(program);
|
|
66
|
+
// Execute program
|
|
67
|
+
program.parse(process.argv);
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,2BAAkC;AAClC,+BAA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AAA,0BAAoB,EAAC,OAAO,CAAC,CAAC;AAC9B,IAAA,gCAAuB,EAAC,OAAO,CAAC,CAAC;AACjC,IAAA,4BAAqB,EAAC,OAAO,CAAC,CAAC;AAE/B,2BAA2B;AAC3B,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;AAE9D,wBAAwB;AACxB,IAAA,wBAAkB,EAAC,OAAO,CAAC,CAAC;AAC5B,IAAA,0BAAmB,EAAC,OAAO,CAAC,CAAC;AAC7B,IAAA,8BAAqB,EAAC,OAAO,CAAC,CAAC;AAC/B,IAAA,8BAAqB,EAAC,OAAO,CAAC,CAAC;AAC/B,IAAA,8BAAqB,EAAC,OAAO,CAAC,CAAC;AAC/B,IAAA,0BAAmB,EAAC,OAAO,CAAC,CAAC;AAE7B,yBAAyB;AACzB,IAAA,yBAAmB,EAAC,OAAO,CAAC,CAAC;AAC7B,IAAA,yBAAmB,EAAC,OAAO,CAAC,CAAC;AAC7B,IAAA,2BAAoB,EAAC,OAAO,CAAC,CAAC;AAC9B,IAAA,+BAAsB,EAAC,OAAO,CAAC,CAAC;AAEhC,kBAAkB;AAClB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array utility functions
|
|
3
|
+
* Provides common array operations used across CLI commands
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Filter out null and undefined values from an array, narrowing the type to NonNullable<T>.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* someIds.map((id) => service.getItem(id)).filter(filterNonNull)
|
|
10
|
+
*
|
|
11
|
+
* @param t - The value to test
|
|
12
|
+
* @returns true if the value is not null or undefined
|
|
13
|
+
*/
|
|
14
|
+
export declare function filterNonNull<T>(t: T): t is NonNullable<T>;
|
|
15
|
+
//# sourceMappingURL=array-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-utils.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/array-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAE1D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Array utility functions
|
|
4
|
+
* Provides common array operations used across CLI commands
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.filterNonNull = filterNonNull;
|
|
8
|
+
/**
|
|
9
|
+
* Filter out null and undefined values from an array, narrowing the type to NonNullable<T>.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* someIds.map((id) => service.getItem(id)).filter(filterNonNull)
|
|
13
|
+
*
|
|
14
|
+
* @param t - The value to test
|
|
15
|
+
* @returns true if the value is not null or undefined
|
|
16
|
+
*/
|
|
17
|
+
function filterNonNull(t) {
|
|
18
|
+
return t !== null && t !== undefined;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=array-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-utils.js","sourceRoot":"","sources":["../../../src/cli/utils/array-utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAWH,sCAEC;AAXD;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAAI,CAAI;IACnC,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handler utility
|
|
3
|
+
* Provides consistent error handling and validation for CLI commands
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Handle and display errors in CLI
|
|
7
|
+
* @param error - The error to handle
|
|
8
|
+
* @param options - Options for error handling
|
|
9
|
+
*/
|
|
10
|
+
export declare function handleError(error: Error, options: {
|
|
11
|
+
json?: boolean;
|
|
12
|
+
}): void;
|
|
13
|
+
/**
|
|
14
|
+
* Validate and parse numeric input
|
|
15
|
+
* @param input - The input string to validate
|
|
16
|
+
* @returns The parsed number, or null if invalid
|
|
17
|
+
*/
|
|
18
|
+
export declare function validateNumberInput(input: string | undefined): number | null;
|
|
19
|
+
/**
|
|
20
|
+
* Validate and parse ID input, exiting with error on invalid input
|
|
21
|
+
* @param input - The input string to validate
|
|
22
|
+
* @param entityName - The entity name for error messages (e.g., "Task", "Tag")
|
|
23
|
+
* @param options - Options for error handling
|
|
24
|
+
* @returns The parsed number
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateIdInput(input: string, entityName: string, options: {
|
|
27
|
+
json?: boolean;
|
|
28
|
+
}): number;
|
|
29
|
+
/**
|
|
30
|
+
* Parse comma-separated numeric array
|
|
31
|
+
* @param input - The input string to parse (e.g., "1,2,3")
|
|
32
|
+
* @returns Array of numbers, or empty array if invalid
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseNumericArray(input: string | undefined): number[];
|
|
35
|
+
//# sourceMappingURL=error-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/error-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAM3E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAW5E;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAWtG;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CAiBrE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Error handler utility
|
|
4
|
+
* Provides consistent error handling and validation for CLI commands
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.handleError = handleError;
|
|
11
|
+
exports.validateNumberInput = validateNumberInput;
|
|
12
|
+
exports.validateIdInput = validateIdInput;
|
|
13
|
+
exports.parseNumericArray = parseNumericArray;
|
|
14
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
15
|
+
const response_formatter_1 = require("./response-formatter");
|
|
16
|
+
/**
|
|
17
|
+
* Handle and display errors in CLI
|
|
18
|
+
* @param error - The error to handle
|
|
19
|
+
* @param options - Options for error handling
|
|
20
|
+
*/
|
|
21
|
+
function handleError(error, options) {
|
|
22
|
+
if (options.json) {
|
|
23
|
+
console.log((0, response_formatter_1.formatJsonError)(error.message));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
console.log(chalk_1.default.red(`\n✗ Error: ${error.message}\n`));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Validate and parse numeric input
|
|
31
|
+
* @param input - The input string to validate
|
|
32
|
+
* @returns The parsed number, or null if invalid
|
|
33
|
+
*/
|
|
34
|
+
function validateNumberInput(input) {
|
|
35
|
+
if (input === undefined) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const parsed = parseInt(input, 10);
|
|
39
|
+
if (isNaN(parsed)) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return parsed;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Validate and parse ID input, exiting with error on invalid input
|
|
46
|
+
* @param input - The input string to validate
|
|
47
|
+
* @param entityName - The entity name for error messages (e.g., "Task", "Tag")
|
|
48
|
+
* @param options - Options for error handling
|
|
49
|
+
* @returns The parsed number
|
|
50
|
+
*/
|
|
51
|
+
function validateIdInput(input, entityName, options) {
|
|
52
|
+
const parsed = parseInt(input, 10);
|
|
53
|
+
if (isNaN(parsed)) {
|
|
54
|
+
if (options.json) {
|
|
55
|
+
console.log((0, response_formatter_1.formatJsonError)(`${entityName} ID must be a number`));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
console.log(chalk_1.default.red(`\nError: ${entityName} ID must be a number\n`));
|
|
59
|
+
}
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
return parsed;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Parse comma-separated numeric array
|
|
66
|
+
* @param input - The input string to parse (e.g., "1,2,3")
|
|
67
|
+
* @returns Array of numbers, or empty array if invalid
|
|
68
|
+
*/
|
|
69
|
+
function parseNumericArray(input) {
|
|
70
|
+
if (input === undefined || input.trim() === '') {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
const parts = input.split(',').map((s) => s.trim());
|
|
74
|
+
const result = [];
|
|
75
|
+
for (const part of parts) {
|
|
76
|
+
const num = parseInt(part, 10);
|
|
77
|
+
if (isNaN(num)) {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
result.push(num);
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../../src/cli/utils/error-handler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAU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AC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,KAAyB;IACzD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC/C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACpD,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YACf,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output formatter
|
|
3
|
+
* OCP-compliant abstraction for CLI output format
|
|
4
|
+
*
|
|
5
|
+
* New output formats (YAML, CSV, etc.) can be added by implementing OutputFormatter
|
|
6
|
+
* without modifying any command files.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Interface for output formatting
|
|
10
|
+
* Implementations determine how data is presented (JSON, text, or future formats)
|
|
11
|
+
*/
|
|
12
|
+
export interface OutputFormatter {
|
|
13
|
+
/**
|
|
14
|
+
* Output data in the appropriate format
|
|
15
|
+
* @param jsonDataProvider - Function that returns JSON-serializable data (lazy, only called in JSON mode)
|
|
16
|
+
* @param textRender - Function that renders text output (only called in text mode)
|
|
17
|
+
*/
|
|
18
|
+
output(jsonDataProvider: () => object, textRender: () => void): void;
|
|
19
|
+
/**
|
|
20
|
+
* Output an error in the appropriate format
|
|
21
|
+
* @param message - Error message
|
|
22
|
+
* @param textRender - Optional custom text renderer; defaults to red error message
|
|
23
|
+
*/
|
|
24
|
+
error(message: string, textRender?: () => void): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Factory function to create an OutputFormatter based on the output mode options
|
|
28
|
+
* @param options - Command options object (checks for json property)
|
|
29
|
+
* @returns An OutputFormatter instance appropriate for the requested format
|
|
30
|
+
*/
|
|
31
|
+
export declare function createFormatter(options: {
|
|
32
|
+
json?: boolean;
|
|
33
|
+
}): OutputFormatter;
|
|
34
|
+
//# sourceMappingURL=output-formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-formatter.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/output-formatter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,EAAE,MAAM,MAAM,EAAE,UAAU,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAErE;;;;OAIG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CACvD;AA0BD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,eAAe,CAE5E"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Output formatter
|
|
4
|
+
* OCP-compliant abstraction for CLI output format
|
|
5
|
+
*
|
|
6
|
+
* New output formats (YAML, CSV, etc.) can be added by implementing OutputFormatter
|
|
7
|
+
* without modifying any command files.
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.createFormatter = createFormatter;
|
|
14
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
15
|
+
class JsonFormatter {
|
|
16
|
+
output(jsonDataProvider) {
|
|
17
|
+
console.log(JSON.stringify(jsonDataProvider(), null, 2));
|
|
18
|
+
}
|
|
19
|
+
error(message) {
|
|
20
|
+
console.log(JSON.stringify({ success: false, error: { message } }, null, 2));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
class TextFormatter {
|
|
24
|
+
output(_jsonDataProvider, textRender) {
|
|
25
|
+
textRender();
|
|
26
|
+
}
|
|
27
|
+
error(message, textRender) {
|
|
28
|
+
if (textRender) {
|
|
29
|
+
textRender();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
console.log(chalk_1.default.red(`\n✗ Error: ${message}\n`));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Factory function to create an OutputFormatter based on the output mode options
|
|
38
|
+
* @param options - Command options object (checks for json property)
|
|
39
|
+
* @returns An OutputFormatter instance appropriate for the requested format
|
|
40
|
+
*/
|
|
41
|
+
function createFormatter(options) {
|
|
42
|
+
return options.json ? new JsonFormatter() : new TextFormatter();
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=output-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-formatter.js","sourceRoot":"","sources":["../../../src/cli/utils/output-formatter.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;AAqDH,0CAEC;AArDD,kDAA0B;AAsB1B,MAAM,aAAa;IACjB,MAAM,CAAC,gBAA8B;QACnC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,KAAK,CAAC,OAAe;QACnB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/E,CAAC;CACF;AAED,MAAM,aAAa;IACjB,MAAM,CAAC,iBAA+B,EAAE,UAAsB;QAC5D,UAAU,EAAE,CAAC;IACf,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,UAAuB;QAC5C,IAAI,UAAU,EAAE,CAAC;YACf,UAAU,EAAE,CAAC;QACf,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,cAAc,OAAO,IAAI,CAAC,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;CACF;AAED;;;;GAIG;AACH,SAAgB,eAAe,CAAC,OAA2B;IACzD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC,CAAC,IAAI,aAAa,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response formatter utility
|
|
3
|
+
* Provides consistent JSON output formatting for CLI commands
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Format a successful response in JSON format
|
|
7
|
+
* @param data - The data to include in the response
|
|
8
|
+
* @param metadata - Optional metadata to include
|
|
9
|
+
* @returns Formatted JSON string
|
|
10
|
+
*/
|
|
11
|
+
export declare function formatJsonSuccess(data: unknown, metadata?: unknown): string;
|
|
12
|
+
/**
|
|
13
|
+
* Format an error response in JSON format
|
|
14
|
+
* @param message - The error message
|
|
15
|
+
* @param code - Optional error code
|
|
16
|
+
* @returns Formatted JSON string
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatJsonError(message: string, code?: string): string;
|
|
19
|
+
//# sourceMappingURL=response-formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-formatter.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/response-formatter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAW3E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAatE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Response formatter utility
|
|
4
|
+
* Provides consistent JSON output formatting for CLI commands
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.formatJsonSuccess = formatJsonSuccess;
|
|
8
|
+
exports.formatJsonError = formatJsonError;
|
|
9
|
+
/**
|
|
10
|
+
* Format a successful response in JSON format
|
|
11
|
+
* @param data - The data to include in the response
|
|
12
|
+
* @param metadata - Optional metadata to include
|
|
13
|
+
* @returns Formatted JSON string
|
|
14
|
+
*/
|
|
15
|
+
function formatJsonSuccess(data, metadata) {
|
|
16
|
+
const response = {
|
|
17
|
+
success: true,
|
|
18
|
+
data,
|
|
19
|
+
};
|
|
20
|
+
if (metadata !== undefined) {
|
|
21
|
+
response.metadata = metadata;
|
|
22
|
+
}
|
|
23
|
+
return JSON.stringify(response, null, 2);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Format an error response in JSON format
|
|
27
|
+
* @param message - The error message
|
|
28
|
+
* @param code - Optional error code
|
|
29
|
+
* @returns Formatted JSON string
|
|
30
|
+
*/
|
|
31
|
+
function formatJsonError(message, code) {
|
|
32
|
+
const response = {
|
|
33
|
+
success: false,
|
|
34
|
+
error: {
|
|
35
|
+
message,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
if (code !== undefined) {
|
|
39
|
+
response.error.code = code;
|
|
40
|
+
}
|
|
41
|
+
return JSON.stringify(response, null, 2);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=response-formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-formatter.js","sourceRoot":"","sources":["../../../src/cli/utils/response-formatter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAQH,8CAWC;AAQD,0CAaC;AAtCD;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,IAAa,EAAE,QAAkB;IACjE,MAAM,QAAQ,GAA4D;QACxE,OAAO,EAAE,IAAI;QACb,IAAI;KACL,CAAC;IAEF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC/B,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,OAAe,EAAE,IAAa;IAC5D,MAAM,QAAQ,GAAoE;QAChF,OAAO,EAAE,KAAK;QACd,KAAK,EAAE;YACL,OAAO;SACR;KACF,CAAC;IAEF,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validators utility
|
|
3
|
+
* Provides validation functions for CLI input
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Validate task status value
|
|
7
|
+
* @param status - The status string to validate
|
|
8
|
+
* @returns true if valid, false otherwise
|
|
9
|
+
*/
|
|
10
|
+
export declare function validateTaskStatus(status: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Validate and convert task ID
|
|
13
|
+
* @param id - The ID value to validate (can be string or number)
|
|
14
|
+
* @returns The validated number ID, or null if invalid
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateTaskId(id: unknown): number | null;
|
|
17
|
+
/**
|
|
18
|
+
* Validate file existence and path safety
|
|
19
|
+
* @param path - The file path to check
|
|
20
|
+
* @returns true if file exists and path is safe, false otherwise
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateFileExists(path: string): boolean;
|
|
23
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/validators.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAG1D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAWzD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAMxD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Validators utility
|
|
4
|
+
* Provides validation functions for CLI input
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.validateTaskStatus = validateTaskStatus;
|
|
8
|
+
exports.validateTaskId = validateTaskId;
|
|
9
|
+
exports.validateFileExists = validateFileExists;
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const security_1 = require("../../utils/security");
|
|
12
|
+
/**
|
|
13
|
+
* Validate task status value
|
|
14
|
+
* @param status - The status string to validate
|
|
15
|
+
* @returns true if valid, false otherwise
|
|
16
|
+
*/
|
|
17
|
+
function validateTaskStatus(status) {
|
|
18
|
+
const validStatuses = ['backlog', 'ready', 'in_progress', 'review', 'done', 'closed'];
|
|
19
|
+
return validStatuses.includes(status);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Validate and convert task ID
|
|
23
|
+
* @param id - The ID value to validate (can be string or number)
|
|
24
|
+
* @returns The validated number ID, or null if invalid
|
|
25
|
+
*/
|
|
26
|
+
function validateTaskId(id) {
|
|
27
|
+
if (typeof id === 'number') {
|
|
28
|
+
return isNaN(id) ? null : id;
|
|
29
|
+
}
|
|
30
|
+
if (typeof id === 'string') {
|
|
31
|
+
const parsed = parseInt(id, 10);
|
|
32
|
+
return isNaN(parsed) ? null : parsed;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Validate file existence and path safety
|
|
38
|
+
* @param path - The file path to check
|
|
39
|
+
* @returns true if file exists and path is safe, false otherwise
|
|
40
|
+
*/
|
|
41
|
+
function validateFileExists(path) {
|
|
42
|
+
if (!(0, security_1.isPathSafe)(path)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return (0, fs_1.existsSync)(path);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/cli/utils/validators.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAWH,gDAGC;AAOD,wCAWC;AAOD,gDAMC;AA3CD,2BAAgC;AAEhC,mDAAkD;AAElD;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,MAAM,aAAa,GAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACpG,OAAO,aAAa,CAAC,QAAQ,CAAC,MAAoB,CAAC,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAC,EAAW;IACxC,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/B,CAAC;IAED,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAChC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;IACvC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,IAAY;IAC7C,IAAI,CAAC,IAAA,qBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAA,eAAU,EAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration file type definition
|
|
3
|
+
*/
|
|
4
|
+
export interface Config {
|
|
5
|
+
path?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Check if running in test mode
|
|
9
|
+
*/
|
|
10
|
+
export declare function isTestMode(): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Get config file name based on current mode
|
|
13
|
+
*/
|
|
14
|
+
export declare function getConfigFileName(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Get default directory name based on current mode
|
|
17
|
+
*/
|
|
18
|
+
export declare function getDefaultDirName(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve database path with priority order:
|
|
21
|
+
* 1. Environment variable: AGENT_KANBAN_DB_PATH (highest priority)
|
|
22
|
+
* 2. Configuration file: .agkan.yml or .agkan-test.yml (mode-specific)
|
|
23
|
+
* 2a. Fallback: .akan.yml or .akan-test.yml (legacy, with migration warning)
|
|
24
|
+
* 3. Default path: .agkan/data.db or .agkan-test/data.db (lowest priority)
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveDatabasePath(): string;
|
|
27
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/db/config.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAEpC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAkBD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAiF5C"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isTestMode = isTestMode;
|
|
7
|
+
exports.getConfigFileName = getConfigFileName;
|
|
8
|
+
exports.getDefaultDirName = getDefaultDirName;
|
|
9
|
+
exports.resolveDatabasePath = resolveDatabasePath;
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
13
|
+
/**
|
|
14
|
+
* Check if running in test mode
|
|
15
|
+
*/
|
|
16
|
+
function isTestMode() {
|
|
17
|
+
return process.env.NODE_ENV === 'test';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get config file name based on current mode
|
|
21
|
+
*/
|
|
22
|
+
function getConfigFileName() {
|
|
23
|
+
return isTestMode() ? '.agkan-test.yml' : '.agkan.yml';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get default directory name based on current mode
|
|
27
|
+
*/
|
|
28
|
+
function getDefaultDirName() {
|
|
29
|
+
return isTestMode() ? '.agkan-test' : '.agkan';
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get legacy config file name for backward compatibility
|
|
33
|
+
*/
|
|
34
|
+
function getLegacyConfigFileName() {
|
|
35
|
+
return isTestMode() ? '.akan-test.yml' : '.akan.yml';
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Check if a resolved database path appears to be a production path.
|
|
39
|
+
* A path is considered a production path if it contains '.agkan'
|
|
40
|
+
* but NOT '.agkan-test'.
|
|
41
|
+
*/
|
|
42
|
+
function isProductionPath(dbPath) {
|
|
43
|
+
return dbPath.includes('.agkan') && !dbPath.includes('.agkan-test');
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Resolve database path with priority order:
|
|
47
|
+
* 1. Environment variable: AGENT_KANBAN_DB_PATH (highest priority)
|
|
48
|
+
* 2. Configuration file: .agkan.yml or .agkan-test.yml (mode-specific)
|
|
49
|
+
* 2a. Fallback: .akan.yml or .akan-test.yml (legacy, with migration warning)
|
|
50
|
+
* 3. Default path: .agkan/data.db or .agkan-test/data.db (lowest priority)
|
|
51
|
+
*/
|
|
52
|
+
function resolveDatabasePath() {
|
|
53
|
+
// Priority 1: Check environment variable
|
|
54
|
+
if (process.env.AGENT_KANBAN_DB_PATH) {
|
|
55
|
+
const envPath = process.env.AGENT_KANBAN_DB_PATH;
|
|
56
|
+
// Resolve relative paths from current working directory
|
|
57
|
+
const resolvedPath = path_1.default.isAbsolute(envPath) ? envPath : path_1.default.join(process.cwd(), envPath);
|
|
58
|
+
// Warn if in test mode but path appears to be a production path
|
|
59
|
+
if (isTestMode() && isProductionPath(resolvedPath)) {
|
|
60
|
+
console.warn(`[WARNING] Running in test mode but AGENT_KANBAN_DB_PATH points to a production path: ${resolvedPath}. ` +
|
|
61
|
+
'This may cause production data to be modified or deleted.');
|
|
62
|
+
}
|
|
63
|
+
return resolvedPath;
|
|
64
|
+
}
|
|
65
|
+
// Priority 2: Check configuration file
|
|
66
|
+
const configFileName = getConfigFileName();
|
|
67
|
+
const configPath = path_1.default.join(process.cwd(), configFileName);
|
|
68
|
+
if (fs_1.default.existsSync(configPath)) {
|
|
69
|
+
try {
|
|
70
|
+
const configContent = fs_1.default.readFileSync(configPath, 'utf8');
|
|
71
|
+
const config = js_yaml_1.default.load(configContent);
|
|
72
|
+
if (config.path) {
|
|
73
|
+
// Resolve relative paths from current working directory
|
|
74
|
+
const dbPath = path_1.default.isAbsolute(config.path) ? config.path : path_1.default.join(process.cwd(), config.path);
|
|
75
|
+
// Warn if in test mode but path appears to be a production path
|
|
76
|
+
if (isTestMode() && isProductionPath(dbPath)) {
|
|
77
|
+
console.warn(`[WARNING] Running in test mode but config file specifies a production path: ${dbPath}. ` +
|
|
78
|
+
'This may cause production data to be modified or deleted.');
|
|
79
|
+
}
|
|
80
|
+
return dbPath;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// Fallback to default path on error (e.g., corrupted YAML)
|
|
85
|
+
// Silent fallback - no warning needed per test expectations
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
// Priority 2a: Fallback to legacy config file (.akan.yml / .akan-test.yml)
|
|
90
|
+
const legacyConfigFileName = getLegacyConfigFileName();
|
|
91
|
+
const legacyConfigPath = path_1.default.join(process.cwd(), legacyConfigFileName);
|
|
92
|
+
if (fs_1.default.existsSync(legacyConfigPath)) {
|
|
93
|
+
console.warn(`[WARNING] Legacy config file '${legacyConfigFileName}' found. ` +
|
|
94
|
+
`Please rename it to '${configFileName}' to suppress this warning.`);
|
|
95
|
+
try {
|
|
96
|
+
const configContent = fs_1.default.readFileSync(legacyConfigPath, 'utf8');
|
|
97
|
+
const config = js_yaml_1.default.load(configContent);
|
|
98
|
+
if (config.path) {
|
|
99
|
+
const dbPath = path_1.default.isAbsolute(config.path) ? config.path : path_1.default.join(process.cwd(), config.path);
|
|
100
|
+
if (isTestMode() && isProductionPath(dbPath)) {
|
|
101
|
+
console.warn(`[WARNING] Running in test mode but config file specifies a production path: ${dbPath}. ` +
|
|
102
|
+
'This may cause production data to be modified or deleted.');
|
|
103
|
+
}
|
|
104
|
+
return dbPath;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// Silent fallback
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Priority 3: Default path
|
|
113
|
+
const defaultDir = getDefaultDirName();
|
|
114
|
+
return path_1.default.join(process.cwd(), defaultDir, 'data.db');
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/db/config.ts"],"names":[],"mappings":";;;;;AAcA,gCAEC;AAKD,8CAEC;AAKD,8CAEC;AAyBD,kDAiFC;AAxID,4CAAoB;AACpB,gDAAwB;AACxB,sDAA2B;AAS3B;;GAEG;AACH,SAAgB,UAAU;IACxB,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB;IAC/B,OAAO,UAAU,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,YAAY,CAAC;AACzD,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB;IAC/B,OAAO,UAAU,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC;AACjD,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB;IAC9B,OAAO,UAAU,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,WAAW,CAAC;AACvD,CAAC;AAED;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,MAAc;IACtC,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAA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