sqlew 3.2.5 → 3.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/CHANGELOG.md +288 -1011
- package/README.md +80 -263
- package/assets/config.example.toml +97 -0
- package/assets/schema.sql +6 -1
- package/dist/adapters/index.d.ts +11 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +21 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/mysql-adapter.d.ts +31 -0
- package/dist/adapters/mysql-adapter.d.ts.map +1 -0
- package/dist/adapters/mysql-adapter.js +63 -0
- package/dist/adapters/mysql-adapter.js.map +1 -0
- package/dist/adapters/postgresql-adapter.d.ts +31 -0
- package/dist/adapters/postgresql-adapter.d.ts.map +1 -0
- package/dist/adapters/postgresql-adapter.js +63 -0
- package/dist/adapters/postgresql-adapter.js.map +1 -0
- package/dist/adapters/sqlite-adapter.d.ts +37 -0
- package/dist/adapters/sqlite-adapter.d.ts.map +1 -0
- package/dist/adapters/sqlite-adapter.js +129 -0
- package/dist/adapters/sqlite-adapter.js.map +1 -0
- package/dist/adapters/types.d.ts +33 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +2 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/cli.js +55 -54
- package/dist/cli.js.map +1 -1
- package/dist/config/example-generator.d.ts +11 -0
- package/dist/config/example-generator.d.ts.map +1 -0
- package/dist/config/example-generator.js +48 -0
- package/dist/config/example-generator.js.map +1 -0
- package/dist/config/loader.d.ts +46 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +155 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/types.d.ts +86 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +28 -0
- package/dist/config/types.js.map +1 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +10 -0
- package/dist/constants.js.map +1 -1
- package/dist/database.d.ts +44 -122
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +145 -349
- package/dist/database.js.map +1 -1
- package/dist/index.js +223 -175
- package/dist/index.js.map +1 -1
- package/dist/knexfile.d.ts +6 -0
- package/dist/knexfile.d.ts.map +1 -0
- package/dist/knexfile.js +85 -0
- package/dist/knexfile.js.map +1 -0
- package/dist/migrations/add-help-system-tables.d.ts +35 -0
- package/dist/migrations/add-help-system-tables.d.ts.map +1 -0
- package/dist/migrations/add-help-system-tables.js +206 -0
- package/dist/migrations/add-help-system-tables.js.map +1 -0
- package/dist/migrations/add-token-tracking.d.ts +28 -0
- package/dist/migrations/add-token-tracking.d.ts.map +1 -0
- package/dist/migrations/add-token-tracking.js +108 -0
- package/dist/migrations/add-token-tracking.js.map +1 -0
- package/dist/migrations/add-v3.5.0-pruned-files.d.ts +26 -0
- package/dist/migrations/add-v3.5.0-pruned-files.d.ts.map +1 -0
- package/dist/migrations/add-v3.5.0-pruned-files.js +107 -0
- package/dist/migrations/add-v3.5.0-pruned-files.js.map +1 -0
- package/dist/migrations/index.d.ts +26 -12
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +162 -20
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/knex/20251025020452_create_master_tables.d.ts +4 -0
- package/dist/migrations/knex/20251025020452_create_master_tables.d.ts.map +1 -0
- package/dist/migrations/knex/20251025020452_create_master_tables.js +65 -0
- package/dist/migrations/knex/20251025020452_create_master_tables.js.map +1 -0
- package/dist/migrations/knex/20251025021152_create_transaction_tables.d.ts +4 -0
- package/dist/migrations/knex/20251025021152_create_transaction_tables.d.ts.map +1 -0
- package/dist/migrations/knex/20251025021152_create_transaction_tables.js +235 -0
- package/dist/migrations/knex/20251025021152_create_transaction_tables.js.map +1 -0
- package/dist/migrations/knex/20251025021351_create_indexes.d.ts +4 -0
- package/dist/migrations/knex/20251025021351_create_indexes.d.ts.map +1 -0
- package/dist/migrations/knex/20251025021351_create_indexes.js +62 -0
- package/dist/migrations/knex/20251025021351_create_indexes.js.map +1 -0
- package/dist/migrations/knex/20251025021416_seed_master_data.d.ts +4 -0
- package/dist/migrations/knex/20251025021416_seed_master_data.d.ts.map +1 -0
- package/dist/migrations/knex/20251025021416_seed_master_data.js +58 -0
- package/dist/migrations/knex/20251025021416_seed_master_data.js.map +1 -0
- package/dist/migrations/knex/20251025070349_create_views.d.ts +4 -0
- package/dist/migrations/knex/20251025070349_create_views.d.ts.map +1 -0
- package/dist/migrations/knex/20251025070349_create_views.js +143 -0
- package/dist/migrations/knex/20251025070349_create_views.js.map +1 -0
- package/dist/migrations/knex/20251025081221_add_link_type_to_task_decision_links.d.ts +4 -0
- package/dist/migrations/knex/20251025081221_add_link_type_to_task_decision_links.d.ts.map +1 -0
- package/dist/migrations/knex/20251025081221_add_link_type_to_task_decision_links.js +15 -0
- package/dist/migrations/knex/20251025081221_add_link_type_to_task_decision_links.js.map +1 -0
- package/dist/migrations/knex/20251025082220_fix_task_dependencies_columns.d.ts +8 -0
- package/dist/migrations/knex/20251025082220_fix_task_dependencies_columns.d.ts.map +1 -0
- package/dist/migrations/knex/20251025082220_fix_task_dependencies_columns.js +12 -0
- package/dist/migrations/knex/20251025082220_fix_task_dependencies_columns.js.map +1 -0
- package/dist/migrations/knex/20251025090000_create_help_system_tables.d.ts +19 -0
- package/dist/migrations/knex/20251025090000_create_help_system_tables.d.ts.map +1 -0
- package/dist/migrations/knex/20251025090000_create_help_system_tables.js +115 -0
- package/dist/migrations/knex/20251025090000_create_help_system_tables.js.map +1 -0
- package/dist/migrations/knex/20251025090100_seed_help_categories_and_use_cases.d.ts +13 -0
- package/dist/migrations/knex/20251025090100_seed_help_categories_and_use_cases.d.ts.map +1 -0
- package/dist/migrations/knex/20251025090100_seed_help_categories_and_use_cases.js +377 -0
- package/dist/migrations/knex/20251025090100_seed_help_categories_and_use_cases.js.map +1 -0
- package/dist/migrations/knex/20251025100000_seed_help_metadata.d.ts +15 -0
- package/dist/migrations/knex/20251025100000_seed_help_metadata.d.ts.map +1 -0
- package/dist/migrations/knex/20251025100000_seed_help_metadata.js +253 -0
- package/dist/migrations/knex/20251025100000_seed_help_metadata.js.map +1 -0
- package/dist/migrations/knex/20251025100100_seed_remaining_use_cases.d.ts +16 -0
- package/dist/migrations/knex/20251025100100_seed_remaining_use_cases.d.ts.map +1 -0
- package/dist/migrations/knex/20251025100100_seed_remaining_use_cases.js +276 -0
- package/dist/migrations/knex/20251025100100_seed_remaining_use_cases.js.map +1 -0
- package/dist/migrations/knex/20251025120000_add_cascade_to_task_dependencies.d.ts +8 -0
- package/dist/migrations/knex/20251025120000_add_cascade_to_task_dependencies.d.ts.map +1 -0
- package/dist/migrations/knex/20251025120000_add_cascade_to_task_dependencies.js +64 -0
- package/dist/migrations/knex/20251025120000_add_cascade_to_task_dependencies.js.map +1 -0
- package/dist/migrations/seed-help-data.d.ts +48 -0
- package/dist/migrations/seed-help-data.d.ts.map +1 -0
- package/dist/migrations/seed-help-data.js +1466 -0
- package/dist/migrations/seed-help-data.js.map +1 -0
- package/dist/migrations/seed-tool-metadata.d.ts +24 -0
- package/dist/migrations/seed-tool-metadata.d.ts.map +1 -0
- package/dist/migrations/seed-tool-metadata.js +392 -0
- package/dist/migrations/seed-tool-metadata.js.map +1 -0
- package/dist/migrations/v3.6.0-help-system-refactor.d.ts +46 -0
- package/dist/migrations/v3.6.0-help-system-refactor.d.ts.map +1 -0
- package/dist/migrations/v3.6.0-help-system-refactor.js +223 -0
- package/dist/migrations/v3.6.0-help-system-refactor.js.map +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +2 -0
- package/dist/schema.js.map +1 -1
- package/dist/tests/git-aware-completion.test.d.ts +6 -0
- package/dist/tests/git-aware-completion.test.d.ts.map +1 -0
- package/dist/tests/git-aware-completion.test.js +160 -0
- package/dist/tests/git-aware-completion.test.js.map +1 -0
- package/dist/tests/help-system.test.d.ts +23 -0
- package/dist/tests/help-system.test.d.ts.map +1 -0
- package/dist/tests/help-system.test.js +374 -0
- package/dist/tests/help-system.test.js.map +1 -0
- package/dist/tests/tasks.auto-pruning-decision-link.test.d.ts +6 -0
- package/dist/tests/tasks.auto-pruning-decision-link.test.d.ts.map +1 -0
- package/dist/tests/tasks.auto-pruning-decision-link.test.js +264 -0
- package/dist/tests/tasks.auto-pruning-decision-link.test.js.map +1 -0
- package/dist/tests/tasks.auto-pruning-partial.test.d.ts +6 -0
- package/dist/tests/tasks.auto-pruning-partial.test.d.ts.map +1 -0
- package/dist/tests/tasks.auto-pruning-partial.test.js +285 -0
- package/dist/tests/tasks.auto-pruning-partial.test.js.map +1 -0
- package/dist/tests/tasks.auto-pruning-persistence.test.d.ts +6 -0
- package/dist/tests/tasks.auto-pruning-persistence.test.d.ts.map +1 -0
- package/dist/tests/tasks.auto-pruning-persistence.test.js +250 -0
- package/dist/tests/tasks.auto-pruning-persistence.test.js.map +1 -0
- package/dist/tests/tasks.auto-pruning-safety.test.d.ts +12 -0
- package/dist/tests/tasks.auto-pruning-safety.test.d.ts.map +1 -0
- package/dist/tests/tasks.auto-pruning-safety.test.js +217 -0
- package/dist/tests/tasks.auto-pruning-safety.test.js.map +1 -0
- package/dist/tests/tasks.dependencies.test.js +338 -307
- package/dist/tests/tasks.dependencies.test.js.map +1 -1
- package/dist/tests/tasks.link-file-backward-compat.test.d.ts +6 -0
- package/dist/tests/tasks.link-file-backward-compat.test.d.ts.map +1 -0
- package/dist/tests/tasks.link-file-backward-compat.test.js +247 -0
- package/dist/tests/tasks.link-file-backward-compat.test.js.map +1 -0
- package/dist/tests/tasks.watch-files-action.test.d.ts +6 -0
- package/dist/tests/tasks.watch-files-action.test.d.ts.map +1 -0
- package/dist/tests/tasks.watch-files-action.test.js +372 -0
- package/dist/tests/tasks.watch-files-action.test.js.map +1 -0
- package/dist/tests/tasks.watch-files-parameter.test.d.ts +6 -0
- package/dist/tests/tasks.watch-files-parameter.test.d.ts.map +1 -0
- package/dist/tests/tasks.watch-files-parameter.test.js +260 -0
- package/dist/tests/tasks.watch-files-parameter.test.js.map +1 -0
- package/dist/tests/two-step-git-completion.test.d.ts +6 -0
- package/dist/tests/two-step-git-completion.test.d.ts.map +1 -0
- package/dist/tests/two-step-git-completion.test.js +326 -0
- package/dist/tests/two-step-git-completion.test.js.map +1 -0
- package/dist/tests/vcs-staging.test.d.ts +6 -0
- package/dist/tests/vcs-staging.test.d.ts.map +1 -0
- package/dist/tests/vcs-staging.test.js +137 -0
- package/dist/tests/vcs-staging.test.js.map +1 -0
- package/dist/tools/config.d.ts +9 -4
- package/dist/tools/config.d.ts.map +1 -1
- package/dist/tools/config.js +16 -12
- package/dist/tools/config.js.map +1 -1
- package/dist/tools/constraints.d.ts +9 -3
- package/dist/tools/constraints.d.ts.map +1 -1
- package/dist/tools/constraints.js +66 -45
- package/dist/tools/constraints.js.map +1 -1
- package/dist/tools/context.d.ts +35 -16
- package/dist/tools/context.d.ts.map +1 -1
- package/dist/tools/context.js +374 -314
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/files.d.ts +11 -4
- package/dist/tools/files.d.ts.map +1 -1
- package/dist/tools/files.js +173 -91
- package/dist/tools/files.js.map +1 -1
- package/dist/tools/help-queries.d.ts +130 -0
- package/dist/tools/help-queries.d.ts.map +1 -0
- package/dist/tools/help-queries.js +393 -0
- package/dist/tools/help-queries.js.map +1 -0
- package/dist/tools/messaging.d.ts +13 -6
- package/dist/tools/messaging.d.ts.map +1 -1
- package/dist/tools/messaging.js +217 -129
- package/dist/tools/messaging.js.map +1 -1
- package/dist/tools/tasks.d.ts +42 -12
- package/dist/tools/tasks.d.ts.map +1 -1
- package/dist/tools/tasks.js +809 -347
- package/dist/tools/tasks.js.map +1 -1
- package/dist/tools/utils.d.ts +13 -5
- package/dist/tools/utils.d.ts.map +1 -1
- package/dist/tools/utils.js +92 -115
- package/dist/tools/utils.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/activity-logging.d.ts +114 -0
- package/dist/utils/activity-logging.d.ts.map +1 -0
- package/dist/utils/activity-logging.js +162 -0
- package/dist/utils/activity-logging.js.map +1 -0
- package/dist/utils/batch.d.ts +2 -2
- package/dist/utils/batch.d.ts.map +1 -1
- package/dist/utils/batch.js +8 -8
- package/dist/utils/batch.js.map +1 -1
- package/dist/utils/cleanup.d.ts +21 -13
- package/dist/utils/cleanup.d.ts.map +1 -1
- package/dist/utils/cleanup.js +31 -24
- package/dist/utils/cleanup.js.map +1 -1
- package/dist/utils/debug-logger.d.ts +44 -0
- package/dist/utils/debug-logger.d.ts.map +1 -0
- package/dist/utils/debug-logger.js +116 -0
- package/dist/utils/debug-logger.js.map +1 -0
- package/dist/utils/file-pruning.d.ts +69 -0
- package/dist/utils/file-pruning.d.ts.map +1 -0
- package/dist/utils/file-pruning.js +185 -0
- package/dist/utils/file-pruning.js.map +1 -0
- package/dist/utils/help-tracking.d.ts +55 -0
- package/dist/utils/help-tracking.d.ts.map +1 -0
- package/dist/utils/help-tracking.js +88 -0
- package/dist/utils/help-tracking.js.map +1 -0
- package/dist/utils/quality-checks.d.ts +60 -0
- package/dist/utils/quality-checks.d.ts.map +1 -0
- package/dist/utils/quality-checks.js +228 -0
- package/dist/utils/quality-checks.js.map +1 -0
- package/dist/utils/retention.d.ts +13 -5
- package/dist/utils/retention.d.ts.map +1 -1
- package/dist/utils/retention.js +20 -8
- package/dist/utils/retention.js.map +1 -1
- package/dist/utils/task-stale-detection.d.ts +77 -7
- package/dist/utils/task-stale-detection.d.ts.map +1 -1
- package/dist/utils/task-stale-detection.js +309 -34
- package/dist/utils/task-stale-detection.js.map +1 -1
- package/dist/utils/token-estimation.d.ts +72 -0
- package/dist/utils/token-estimation.d.ts.map +1 -0
- package/dist/utils/token-estimation.js +71 -0
- package/dist/utils/token-estimation.js.map +1 -0
- package/dist/utils/token-logging.d.ts +48 -0
- package/dist/utils/token-logging.d.ts.map +1 -0
- package/dist/utils/token-logging.js +112 -0
- package/dist/utils/token-logging.js.map +1 -0
- package/dist/utils/vcs-adapter.d.ts +68 -0
- package/dist/utils/vcs-adapter.d.ts.map +1 -0
- package/dist/utils/vcs-adapter.js +187 -0
- package/dist/utils/vcs-adapter.js.map +1 -0
- package/dist/utils/view-queries.d.ts +34 -0
- package/dist/utils/view-queries.d.ts.map +1 -0
- package/dist/utils/view-queries.js +192 -0
- package/dist/utils/view-queries.js.map +1 -0
- package/dist/watcher/file-watcher.d.ts +54 -4
- package/dist/watcher/file-watcher.d.ts.map +1 -1
- package/dist/watcher/file-watcher.js +329 -33
- package/dist/watcher/file-watcher.js.map +1 -1
- package/dist/watcher/gitignore-parser.d.ts +70 -0
- package/dist/watcher/gitignore-parser.d.ts.map +1 -0
- package/dist/watcher/gitignore-parser.js +191 -0
- package/dist/watcher/gitignore-parser.js.map +1 -0
- package/dist/watcher/index.d.ts +1 -0
- package/dist/watcher/index.d.ts.map +1 -1
- package/dist/watcher/index.js +1 -0
- package/dist/watcher/index.js.map +1 -1
- package/docs/AI_AGENT_GUIDE.md +1 -1
- package/docs/ARCHITECTURE.md +12 -0
- package/docs/AUTO_FILE_TRACKING.md +486 -82
- package/docs/BEST_PRACTICES.md +56 -448
- package/docs/CONFIGURATION.md +908 -0
- package/docs/GIT_AWARE_AUTO_COMPLETE.md +645 -0
- package/docs/MIGRATION_v3.3.md +602 -0
- package/docs/MIGRATION_v3.6.0.md +170 -0
- package/docs/SHARED_CONCEPTS.md +65 -209
- package/docs/TASK_ACTIONS.md +12 -0
- package/docs/TASK_OVERVIEW.md +125 -24
- package/docs/TASK_PRUNING.md +589 -0
- package/docs/TASK_SYSTEM.md +83 -13
- package/docs/TOOL_REFERENCE.md +94 -6
- package/docs/TOOL_SELECTION.md +41 -248
- package/package.json +21 -7
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Help Action Usage Tracking
|
|
3
|
+
*
|
|
4
|
+
* Lightweight logging system to track help/example action invocations
|
|
5
|
+
* for understanding usage patterns and optimizing documentation.
|
|
6
|
+
*
|
|
7
|
+
* Data collected:
|
|
8
|
+
* - tool_name: Which MCP tool invoked help/example
|
|
9
|
+
* - action_name: "help" or "example"
|
|
10
|
+
* - timestamp: When the action was invoked
|
|
11
|
+
* - token_count: Estimated tokens in request + response
|
|
12
|
+
*
|
|
13
|
+
* Storage: Temporary log file in .sqlew/tmp/help-usage.log
|
|
14
|
+
* Format: JSON lines (one JSON object per line for easy parsing)
|
|
15
|
+
* Retention: Manual cleanup after 1-2 week analysis period
|
|
16
|
+
*/
|
|
17
|
+
import { appendFileSync, existsSync, mkdirSync } from 'fs';
|
|
18
|
+
import { resolve } from 'path';
|
|
19
|
+
/**
|
|
20
|
+
* Log file configuration
|
|
21
|
+
*/
|
|
22
|
+
const LOG_DIR = resolve(process.cwd(), '.sqlew', 'tmp');
|
|
23
|
+
const LOG_FILE = resolve(LOG_DIR, 'help-usage.log');
|
|
24
|
+
/**
|
|
25
|
+
* Initialize logging directory
|
|
26
|
+
* Creates .sqlew/tmp/ if it doesn't exist
|
|
27
|
+
*/
|
|
28
|
+
function ensureLogDirectory() {
|
|
29
|
+
if (!existsSync(LOG_DIR)) {
|
|
30
|
+
mkdirSync(LOG_DIR, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Log a help action invocation
|
|
35
|
+
* Appends JSON line to log file for analysis
|
|
36
|
+
*
|
|
37
|
+
* @param record - Help usage record to log
|
|
38
|
+
*/
|
|
39
|
+
export function logHelpUsage(record) {
|
|
40
|
+
try {
|
|
41
|
+
ensureLogDirectory();
|
|
42
|
+
// Append as JSON line (newline-delimited JSON)
|
|
43
|
+
const jsonLine = JSON.stringify(record) + '\n';
|
|
44
|
+
appendFileSync(LOG_FILE, jsonLine, 'utf8');
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
// Silent failure - don't break tool execution if logging fails
|
|
48
|
+
console.error('[Help Tracking] Failed to log usage:', error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Estimate token count for help/example action
|
|
53
|
+
* Rough estimation based on response length
|
|
54
|
+
*
|
|
55
|
+
* @param toolName - Name of the MCP tool
|
|
56
|
+
* @param actionName - "help" or "example"
|
|
57
|
+
* @param responseLength - Length of response text
|
|
58
|
+
* @returns Estimated token count (request + response)
|
|
59
|
+
*/
|
|
60
|
+
export function estimateHelpTokens(toolName, actionName, responseLength) {
|
|
61
|
+
// Request tokens: tool name + action parameter (~50 tokens)
|
|
62
|
+
const requestTokens = 50;
|
|
63
|
+
// Response tokens: approximate 4 chars per token
|
|
64
|
+
const responseTokens = Math.ceil(responseLength / 4);
|
|
65
|
+
return requestTokens + responseTokens;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Track help action and return the help content
|
|
69
|
+
* Convenience wrapper that logs and returns content
|
|
70
|
+
*
|
|
71
|
+
* @param toolName - Name of the MCP tool
|
|
72
|
+
* @param actionName - "help" or "example"
|
|
73
|
+
* @param content - Help content to return
|
|
74
|
+
* @param context - Optional context about what triggered help
|
|
75
|
+
* @returns The help content (pass-through)
|
|
76
|
+
*/
|
|
77
|
+
export function trackAndReturnHelp(toolName, actionName, content, context) {
|
|
78
|
+
const tokenCount = estimateHelpTokens(toolName, actionName, content.length);
|
|
79
|
+
logHelpUsage({
|
|
80
|
+
tool_name: toolName,
|
|
81
|
+
action_name: actionName,
|
|
82
|
+
timestamp: new Date().toISOString(),
|
|
83
|
+
token_count: tokenCount,
|
|
84
|
+
context
|
|
85
|
+
});
|
|
86
|
+
return content;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=help-tracking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help-tracking.js","sourceRoot":"","sources":["../../src/utils/help-tracking.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AA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,EAAE,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAE5E,YAAY,CAAC;QACX,SAAS,EAAE,QAAQ;QACnB,WAAW,EAAE,UAAU;QACvB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,WAAW,EAAE,UAAU;QACvB,OAAO;KACR,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quality Checks - Validation functions for smart review detection
|
|
3
|
+
* Determines when tasks are ready for review based on quality gates
|
|
4
|
+
*/
|
|
5
|
+
import type { Database } from 'better-sqlite3';
|
|
6
|
+
/**
|
|
7
|
+
* Quality check result
|
|
8
|
+
*/
|
|
9
|
+
export interface QualityCheckResult {
|
|
10
|
+
passed: boolean;
|
|
11
|
+
message: string;
|
|
12
|
+
details?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Check if all watched files for a task have been modified at least once
|
|
16
|
+
*
|
|
17
|
+
* @param db - Database connection
|
|
18
|
+
* @param taskId - Task ID to check
|
|
19
|
+
* @param modifiedFiles - Set of files that have been modified
|
|
20
|
+
* @returns True if all watched files have been modified, false otherwise
|
|
21
|
+
*/
|
|
22
|
+
export declare function checkAllFilesModified(db: Database, taskId: number, modifiedFiles: Set<string>): QualityCheckResult;
|
|
23
|
+
/**
|
|
24
|
+
* Check if TypeScript files compile without syntax errors
|
|
25
|
+
*
|
|
26
|
+
* @param filePaths - Array of file paths to check
|
|
27
|
+
* @returns Promise resolving to true if TypeScript compiles, false otherwise
|
|
28
|
+
*/
|
|
29
|
+
export declare function checkTypeScriptCompiles(filePaths: string[]): Promise<QualityCheckResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Check if tests pass for the task
|
|
32
|
+
*
|
|
33
|
+
* @param db - Database connection
|
|
34
|
+
* @param taskId - Task ID to check
|
|
35
|
+
* @param filePaths - Array of file paths being watched
|
|
36
|
+
* @returns Promise resolving to true if tests pass, false otherwise
|
|
37
|
+
*/
|
|
38
|
+
export declare function checkTestsPass(db: Database, taskId: number, filePaths: string[]): Promise<QualityCheckResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Check if task is ready for review based on all quality gates
|
|
41
|
+
*
|
|
42
|
+
* @param db - Database connection
|
|
43
|
+
* @param taskId - Task ID to check
|
|
44
|
+
* @param filePaths - Array of file paths being watched
|
|
45
|
+
* @param modifiedFiles - Set of files that have been modified
|
|
46
|
+
* @param config - Configuration flags for which checks to run
|
|
47
|
+
* @returns Promise resolving to object with overall result and individual check results
|
|
48
|
+
*/
|
|
49
|
+
export declare function checkReadyForReview(db: Database, taskId: number, filePaths: string[], modifiedFiles: Set<string>, config: {
|
|
50
|
+
requireAllFilesModified: boolean;
|
|
51
|
+
requireTestsPass: boolean;
|
|
52
|
+
requireCompile: boolean;
|
|
53
|
+
}): Promise<{
|
|
54
|
+
ready: boolean;
|
|
55
|
+
results: Array<{
|
|
56
|
+
check: string;
|
|
57
|
+
result: QualityCheckResult;
|
|
58
|
+
}>;
|
|
59
|
+
}>;
|
|
60
|
+
//# sourceMappingURL=quality-checks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quality-checks.d.ts","sourceRoot":"","sources":["../../src/utils/quality-checks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,GACzB,kBAAkB,CA8CpB;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA8C9F;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,kBAAkB,CAAC,CA4F7B;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EAAE,EACnB,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,EAC1B,MAAM,EAAE;IACN,uBAAuB,EAAE,OAAO,CAAC;IACjC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC;CACzB,GACA,OAAO,CAAC;IACT,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,kBAAkB,CAAA;KAAE,CAAC,CAAC;CAC/D,CAAC,CAuBD"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quality Checks - Validation functions for smart review detection
|
|
3
|
+
* Determines when tasks are ready for review based on quality gates
|
|
4
|
+
*/
|
|
5
|
+
import { exec } from 'child_process';
|
|
6
|
+
import { promisify } from 'util';
|
|
7
|
+
const execAsync = promisify(exec);
|
|
8
|
+
/**
|
|
9
|
+
* Check if all watched files for a task have been modified at least once
|
|
10
|
+
*
|
|
11
|
+
* @param db - Database connection
|
|
12
|
+
* @param taskId - Task ID to check
|
|
13
|
+
* @param modifiedFiles - Set of files that have been modified
|
|
14
|
+
* @returns True if all watched files have been modified, false otherwise
|
|
15
|
+
*/
|
|
16
|
+
export function checkAllFilesModified(db, taskId, modifiedFiles) {
|
|
17
|
+
try {
|
|
18
|
+
// Get all watched files for this task
|
|
19
|
+
const stmt = db.prepare(`
|
|
20
|
+
SELECT f.path
|
|
21
|
+
FROM t_task_file_links tfl
|
|
22
|
+
JOIN m_files f ON f.id = tfl.file_id
|
|
23
|
+
WHERE tfl.task_id = ?
|
|
24
|
+
`);
|
|
25
|
+
const watchedFiles = stmt.all(taskId);
|
|
26
|
+
if (watchedFiles.length === 0) {
|
|
27
|
+
// No files to watch - consider this check passed
|
|
28
|
+
return {
|
|
29
|
+
passed: true,
|
|
30
|
+
message: 'No files being watched (check skipped)',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// Check if all watched files have been modified
|
|
34
|
+
const unmodifiedFiles = [];
|
|
35
|
+
for (const { path } of watchedFiles) {
|
|
36
|
+
if (!modifiedFiles.has(path)) {
|
|
37
|
+
unmodifiedFiles.push(path);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (unmodifiedFiles.length === 0) {
|
|
41
|
+
return {
|
|
42
|
+
passed: true,
|
|
43
|
+
message: `All ${watchedFiles.length} watched files have been modified`,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return {
|
|
48
|
+
passed: false,
|
|
49
|
+
message: `${unmodifiedFiles.length} of ${watchedFiles.length} watched files not yet modified`,
|
|
50
|
+
details: `Unmodified: ${unmodifiedFiles.slice(0, 3).join(', ')}${unmodifiedFiles.length > 3 ? '...' : ''}`,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
return {
|
|
56
|
+
passed: false,
|
|
57
|
+
message: `Error checking file modifications: ${error instanceof Error ? error.message : String(error)}`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Check if TypeScript files compile without syntax errors
|
|
63
|
+
*
|
|
64
|
+
* @param filePaths - Array of file paths to check
|
|
65
|
+
* @returns Promise resolving to true if TypeScript compiles, false otherwise
|
|
66
|
+
*/
|
|
67
|
+
export async function checkTypeScriptCompiles(filePaths) {
|
|
68
|
+
try {
|
|
69
|
+
// Filter for TypeScript files
|
|
70
|
+
const tsFiles = filePaths.filter(path => path.endsWith('.ts') || path.endsWith('.tsx'));
|
|
71
|
+
if (tsFiles.length === 0) {
|
|
72
|
+
return {
|
|
73
|
+
passed: true,
|
|
74
|
+
message: 'No TypeScript files to check (check skipped)',
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// Run tsc --noEmit to check for syntax errors
|
|
78
|
+
// This checks the entire project, not just individual files,
|
|
79
|
+
// because TypeScript needs full context for type checking
|
|
80
|
+
try {
|
|
81
|
+
const { stdout, stderr } = await execAsync('npx tsc --noEmit', {
|
|
82
|
+
timeout: 30000, // 30 second timeout
|
|
83
|
+
maxBuffer: 1024 * 1024 * 5, // 5MB buffer
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
passed: true,
|
|
87
|
+
message: `TypeScript compilation successful (${tsFiles.length} .ts/.tsx files)`,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
// tsc returns non-zero exit code if there are errors
|
|
92
|
+
const output = (error.stdout || '') + (error.stderr || '');
|
|
93
|
+
const errorLines = output.split('\n').filter((line) => line.includes('error TS')).slice(0, 3); // First 3 errors
|
|
94
|
+
return {
|
|
95
|
+
passed: false,
|
|
96
|
+
message: 'TypeScript compilation failed',
|
|
97
|
+
details: errorLines.join('\n') || output.slice(0, 300),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
return {
|
|
103
|
+
passed: false,
|
|
104
|
+
message: `Error running TypeScript check: ${error instanceof Error ? error.message : String(error)}`,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Check if tests pass for the task
|
|
110
|
+
*
|
|
111
|
+
* @param db - Database connection
|
|
112
|
+
* @param taskId - Task ID to check
|
|
113
|
+
* @param filePaths - Array of file paths being watched
|
|
114
|
+
* @returns Promise resolving to true if tests pass, false otherwise
|
|
115
|
+
*/
|
|
116
|
+
export async function checkTestsPass(db, taskId, filePaths) {
|
|
117
|
+
try {
|
|
118
|
+
// Check if any files match test patterns
|
|
119
|
+
const testPatterns = [/\.test\.(ts|tsx|js|jsx)$/, /\.spec\.(ts|tsx|js|jsx)$/];
|
|
120
|
+
const testFiles = filePaths.filter(path => testPatterns.some(pattern => pattern.test(path)));
|
|
121
|
+
if (testFiles.length === 0) {
|
|
122
|
+
return {
|
|
123
|
+
passed: true,
|
|
124
|
+
message: 'No test files found (check skipped)',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
// Look for acceptance_criteria with tests_pass type
|
|
128
|
+
const stmt = db.prepare(`
|
|
129
|
+
SELECT acceptance_criteria
|
|
130
|
+
FROM t_task_details
|
|
131
|
+
WHERE task_id = ?
|
|
132
|
+
`);
|
|
133
|
+
const row = stmt.get(taskId);
|
|
134
|
+
if (!row?.acceptance_criteria) {
|
|
135
|
+
// No acceptance criteria - run default test command if package.json has test script
|
|
136
|
+
return {
|
|
137
|
+
passed: true,
|
|
138
|
+
message: 'No test acceptance criteria defined (check skipped)',
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
const criteria = JSON.parse(row.acceptance_criteria);
|
|
142
|
+
const testCriteria = criteria.find((c) => c.type === 'tests_pass');
|
|
143
|
+
if (!testCriteria) {
|
|
144
|
+
return {
|
|
145
|
+
passed: true,
|
|
146
|
+
message: 'No test acceptance criteria defined (check skipped)',
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
// Execute the test command
|
|
150
|
+
const command = testCriteria.command || 'npm test';
|
|
151
|
+
const timeout = testCriteria.timeout || 60; // Default 60s timeout
|
|
152
|
+
try {
|
|
153
|
+
const { stdout, stderr } = await execAsync(command, {
|
|
154
|
+
timeout: timeout * 1000,
|
|
155
|
+
maxBuffer: 1024 * 1024 * 10, // 10MB buffer
|
|
156
|
+
});
|
|
157
|
+
const output = stdout + stderr;
|
|
158
|
+
// Check for expected pattern if specified
|
|
159
|
+
if (testCriteria.expected_pattern) {
|
|
160
|
+
const regex = new RegExp(testCriteria.expected_pattern);
|
|
161
|
+
if (regex.test(output)) {
|
|
162
|
+
return {
|
|
163
|
+
passed: true,
|
|
164
|
+
message: `Tests passed (${testFiles.length} test files)`,
|
|
165
|
+
details: `Command: ${command}`,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
return {
|
|
170
|
+
passed: false,
|
|
171
|
+
message: 'Tests ran but output does not match expected pattern',
|
|
172
|
+
details: output.slice(0, 300),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// No pattern specified - success if exit code is 0
|
|
177
|
+
return {
|
|
178
|
+
passed: true,
|
|
179
|
+
message: `Tests passed (${testFiles.length} test files)`,
|
|
180
|
+
details: `Command: ${command}`,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
const output = (error.stdout || '') + (error.stderr || '');
|
|
185
|
+
return {
|
|
186
|
+
passed: false,
|
|
187
|
+
message: error.killed ? 'Tests timed out' : 'Tests failed',
|
|
188
|
+
details: output.slice(0, 300),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
return {
|
|
194
|
+
passed: false,
|
|
195
|
+
message: `Error running tests: ${error instanceof Error ? error.message : String(error)}`,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Check if task is ready for review based on all quality gates
|
|
201
|
+
*
|
|
202
|
+
* @param db - Database connection
|
|
203
|
+
* @param taskId - Task ID to check
|
|
204
|
+
* @param filePaths - Array of file paths being watched
|
|
205
|
+
* @param modifiedFiles - Set of files that have been modified
|
|
206
|
+
* @param config - Configuration flags for which checks to run
|
|
207
|
+
* @returns Promise resolving to object with overall result and individual check results
|
|
208
|
+
*/
|
|
209
|
+
export async function checkReadyForReview(db, taskId, filePaths, modifiedFiles, config) {
|
|
210
|
+
const results = [];
|
|
211
|
+
// Run all enabled checks
|
|
212
|
+
if (config.requireAllFilesModified) {
|
|
213
|
+
const result = checkAllFilesModified(db, taskId, modifiedFiles);
|
|
214
|
+
results.push({ check: 'all_files_modified', result });
|
|
215
|
+
}
|
|
216
|
+
if (config.requireCompile) {
|
|
217
|
+
const result = await checkTypeScriptCompiles(filePaths);
|
|
218
|
+
results.push({ check: 'typescript_compiles', result });
|
|
219
|
+
}
|
|
220
|
+
if (config.requireTestsPass) {
|
|
221
|
+
const result = await checkTestsPass(db, taskId, filePaths);
|
|
222
|
+
results.push({ check: 'tests_pass', result });
|
|
223
|
+
}
|
|
224
|
+
// All enabled checks must pass
|
|
225
|
+
const ready = results.every(({ result }) => result.passed);
|
|
226
|
+
return { ready, results };
|
|
227
|
+
}
|
|
228
|
+
//# sourceMappingURL=quality-checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quality-checks.js","sourceRoot":"","sources":["../../src/utils/quality-checks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAGjC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAWlC;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,EAAY,EACZ,MAAc,EACd,aAA0B;IAE1B,IAAI,CAAC;QACH,sCAAsC;QACtC,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC;;;;;KAKvB,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAA4B,CAAC;QAEjE,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,iDAAiD;YACjD,OAAO;gBACL,MAAM,EAAE,IAAI;gBACZ,O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GAAG,MAAM,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QAC3D,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,+BAA+B;IAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE3D,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -2,23 +2,31 @@
|
|
|
2
2
|
* Weekend-aware retention logic for auto-deletion
|
|
3
3
|
* Calculates cutoff timestamps that skip weekends when configured
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { DatabaseAdapter } from '../adapters/index.js';
|
|
6
6
|
/**
|
|
7
7
|
* Calculate cutoff timestamp for message retention
|
|
8
8
|
* Respects weekend-awareness configuration
|
|
9
9
|
*
|
|
10
|
-
* @param
|
|
10
|
+
* @param adapter - Database adapter instance
|
|
11
11
|
* @returns Unix timestamp (seconds) for cutoff
|
|
12
12
|
*/
|
|
13
|
-
export declare function calculateMessageCutoff(
|
|
13
|
+
export declare function calculateMessageCutoff(adapter: DatabaseAdapter): Promise<number>;
|
|
14
14
|
/**
|
|
15
15
|
* Calculate cutoff timestamp for file change retention
|
|
16
16
|
* Respects weekend-awareness configuration
|
|
17
17
|
*
|
|
18
|
-
* @param
|
|
18
|
+
* @param adapter - Database adapter instance
|
|
19
19
|
* @returns Unix timestamp (seconds) for cutoff
|
|
20
20
|
*/
|
|
21
|
-
export declare function calculateFileChangeCutoff(
|
|
21
|
+
export declare function calculateFileChangeCutoff(adapter: DatabaseAdapter): Promise<number>;
|
|
22
|
+
/**
|
|
23
|
+
* Calculate cutoff timestamp for task archive (done → archived)
|
|
24
|
+
* Respects weekend-awareness configuration
|
|
25
|
+
*
|
|
26
|
+
* @param adapter - Database adapter instance
|
|
27
|
+
* @returns Unix timestamp (seconds) for cutoff
|
|
28
|
+
*/
|
|
29
|
+
export declare function calculateTaskArchiveCutoff(adapter: DatabaseAdapter): Promise<number>;
|
|
22
30
|
/**
|
|
23
31
|
* Calculate cutoff timestamp with optional weekend-awareness
|
|
24
32
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retention.d.ts","sourceRoot":"","sources":["../../src/utils/retention.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"retention.d.ts","sourceRoot":"","sources":["../../src/utils/retention.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAKtF;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAKzF;AAED;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAK1F;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,OAAO,EACvB,IAAI,EAAE,OAAO,GAAG,MAAM,GACrB,MAAM,CAYR;AA4CD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,GAAG,MAAM,CAavE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAe9D"}
|
package/dist/utils/retention.js
CHANGED
|
@@ -8,24 +8,36 @@ import { CONFIG_KEYS } from '../constants.js';
|
|
|
8
8
|
* Calculate cutoff timestamp for message retention
|
|
9
9
|
* Respects weekend-awareness configuration
|
|
10
10
|
*
|
|
11
|
-
* @param
|
|
11
|
+
* @param adapter - Database adapter instance
|
|
12
12
|
* @returns Unix timestamp (seconds) for cutoff
|
|
13
13
|
*/
|
|
14
|
-
export function calculateMessageCutoff(
|
|
15
|
-
const ignoreWeekends = getConfigBool(
|
|
16
|
-
const retentionHours = getConfigInt(
|
|
14
|
+
export async function calculateMessageCutoff(adapter) {
|
|
15
|
+
const ignoreWeekends = await getConfigBool(adapter, CONFIG_KEYS.AUTODELETE_IGNORE_WEEKEND, false);
|
|
16
|
+
const retentionHours = await getConfigInt(adapter, CONFIG_KEYS.AUTODELETE_MESSAGE_HOURS, 24);
|
|
17
17
|
return calculateCutoffTimestamp(retentionHours, ignoreWeekends, 'hours');
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Calculate cutoff timestamp for file change retention
|
|
21
21
|
* Respects weekend-awareness configuration
|
|
22
22
|
*
|
|
23
|
-
* @param
|
|
23
|
+
* @param adapter - Database adapter instance
|
|
24
24
|
* @returns Unix timestamp (seconds) for cutoff
|
|
25
25
|
*/
|
|
26
|
-
export function calculateFileChangeCutoff(
|
|
27
|
-
const ignoreWeekends = getConfigBool(
|
|
28
|
-
const retentionDays = getConfigInt(
|
|
26
|
+
export async function calculateFileChangeCutoff(adapter) {
|
|
27
|
+
const ignoreWeekends = await getConfigBool(adapter, CONFIG_KEYS.AUTODELETE_IGNORE_WEEKEND, false);
|
|
28
|
+
const retentionDays = await getConfigInt(adapter, CONFIG_KEYS.AUTODELETE_FILE_HISTORY_DAYS, 7);
|
|
29
|
+
return calculateCutoffTimestamp(retentionDays, ignoreWeekends, 'days');
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Calculate cutoff timestamp for task archive (done → archived)
|
|
33
|
+
* Respects weekend-awareness configuration
|
|
34
|
+
*
|
|
35
|
+
* @param adapter - Database adapter instance
|
|
36
|
+
* @returns Unix timestamp (seconds) for cutoff
|
|
37
|
+
*/
|
|
38
|
+
export async function calculateTaskArchiveCutoff(adapter) {
|
|
39
|
+
const ignoreWeekends = await getConfigBool(adapter, CONFIG_KEYS.AUTODELETE_IGNORE_WEEKEND, false);
|
|
40
|
+
const retentionDays = await getConfigInt(adapter, CONFIG_KEYS.AUTO_ARCHIVE_DONE_DAYS, 2); // Default: 2 days (48 hours)
|
|
29
41
|
return calculateCutoffTimestamp(retentionDays, ignoreWeekends, 'days');
|
|
30
42
|
}
|
|
31
43
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retention.js","sourceRoot":"","sources":["../../src/utils/retention.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,
|
|
1
|
+
{"version":3,"file":"retention.js","sourceRoot":"","sources":["../../src/utils/retention.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,OAAwB;IACnE,MAAM,cAAc,GAAG,MAAM,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;IAClG,MAAM,cAAc,GAAG,MAAM,YAAY,CAAC,OAAO,EAAE,WAAW,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAC;IAE7F,OAAO,wBAAwB,CAAC,cAAc,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,OAAwB;IACtE,MAAM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,EAAE,CAAC;QAC1B,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QACnC,IAAI,SAAS,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;YACvC,KAAK,EAAE,CAAC;QACV,CAAC;QACD,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,IAAU,EAAE,IAAY;IACtD,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,SAAS,GAAG,IAAI,CAAC;IAErB,OAAO,SAAS,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;QAErC,2CAA2C;QAC3C,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QAClC,IAAI,SAAS,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;YACvC,SAAS,EAAE,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,28 +1,98 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Auto-stale detection for Kanban Task Watcher
|
|
3
3
|
* Automatically transitions abandoned tasks based on time thresholds
|
|
4
|
+
*
|
|
5
|
+
* CONVERTED: Using Knex.js with DatabaseAdapter (async/await)
|
|
4
6
|
*/
|
|
5
|
-
import {
|
|
7
|
+
import { DatabaseAdapter } from '../adapters/index.js';
|
|
6
8
|
/**
|
|
7
9
|
* Detect and transition stale tasks automatically
|
|
8
10
|
*
|
|
9
11
|
* Detection logic:
|
|
10
12
|
* - Tasks in `in_progress` with `updated_ts` older than threshold → move to `waiting_review`
|
|
11
|
-
* - Tasks in `waiting_review` with `updated_ts` older than threshold → move to `todo`
|
|
12
13
|
*
|
|
13
|
-
* @param
|
|
14
|
+
* @param adapter - Database adapter instance
|
|
14
15
|
* @returns Count of transitioned tasks
|
|
15
16
|
*/
|
|
16
|
-
export declare function detectAndTransitionStaleTasks(
|
|
17
|
+
export declare function detectAndTransitionStaleTasks(adapter?: DatabaseAdapter): Promise<number>;
|
|
17
18
|
/**
|
|
18
19
|
* Get current auto-stale configuration
|
|
19
20
|
*
|
|
20
|
-
* @param
|
|
21
|
+
* @param adapter - Database adapter instance
|
|
21
22
|
* @returns Current configuration values
|
|
22
23
|
*/
|
|
23
|
-
export declare function getStaleDetectionConfig(
|
|
24
|
+
export declare function getStaleDetectionConfig(adapter?: DatabaseAdapter): Promise<{
|
|
24
25
|
enabled: boolean;
|
|
25
26
|
inProgressThresholdHours: number;
|
|
26
27
|
waitingReviewThresholdHours: number;
|
|
27
|
-
}
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* Auto-archive old done tasks
|
|
31
|
+
* Archives tasks in 'done' status older than configured threshold
|
|
32
|
+
* Uses weekend-aware retention logic (consistent with messages/files)
|
|
33
|
+
*
|
|
34
|
+
* Default: 48 hours (2 days)
|
|
35
|
+
* Weekend-aware: Task done Friday → archives Tuesday (skip Sat/Sun)
|
|
36
|
+
*
|
|
37
|
+
* @param adapter - Database adapter instance
|
|
38
|
+
* @returns Count of archived tasks
|
|
39
|
+
*/
|
|
40
|
+
export declare function autoArchiveOldDoneTasks(adapter?: DatabaseAdapter): Promise<number>;
|
|
41
|
+
/**
|
|
42
|
+
* Detect and complete tasks in waiting_review or in_progress when all watched files are committed
|
|
43
|
+
*
|
|
44
|
+
* VCS-aware auto-complete strategy (v3.4.0+):
|
|
45
|
+
* - Find all tasks in `waiting_review` or `in_progress` status with watched files
|
|
46
|
+
* - For each task, check if ALL watched files have been committed since task creation
|
|
47
|
+
* - Query VCS history to determine committed files
|
|
48
|
+
* - If all files committed → transition to `done` (VCS commit = implicit approval)
|
|
49
|
+
* - Supports multiple VCS: Git, Mercurial, SVN
|
|
50
|
+
* - Gracefully handle non-VCS repos (skip auto-complete)
|
|
51
|
+
*
|
|
52
|
+
* @param adapter - Database adapter instance
|
|
53
|
+
* @returns Count of auto-completed tasks
|
|
54
|
+
*/
|
|
55
|
+
export declare function detectAndCompleteReviewedTasks(adapter?: DatabaseAdapter): Promise<number>;
|
|
56
|
+
/**
|
|
57
|
+
* Detect and auto-complete tasks in waiting_review when all watched files are staged
|
|
58
|
+
* (v3.5.2 - Two-step Git-aware workflow: staging → done)
|
|
59
|
+
*
|
|
60
|
+
* Logic:
|
|
61
|
+
* - Find all tasks in waiting_review status
|
|
62
|
+
* - Check if ALL watched files are staged (git add)
|
|
63
|
+
* - If yes → transition to done
|
|
64
|
+
* - Respects git_auto_complete_on_stage config
|
|
65
|
+
*
|
|
66
|
+
* @param db - Database instance
|
|
67
|
+
* @returns Count of auto-completed tasks
|
|
68
|
+
*/
|
|
69
|
+
export declare function detectAndCompleteOnStaging(adapter?: DatabaseAdapter): Promise<number>;
|
|
70
|
+
/**
|
|
71
|
+
* Detect and auto-archive tasks in done when all watched files are committed
|
|
72
|
+
* (v3.5.2 - Two-step Git-aware workflow: commit → archived)
|
|
73
|
+
*
|
|
74
|
+
* Logic:
|
|
75
|
+
* - Find all tasks in done status
|
|
76
|
+
* - Check if ALL watched files are committed (git commit)
|
|
77
|
+
* - If yes → transition to archived
|
|
78
|
+
* - Respects git_auto_archive_on_commit config
|
|
79
|
+
*
|
|
80
|
+
* @param db - Database instance
|
|
81
|
+
* @returns Count of auto-archived tasks
|
|
82
|
+
*/
|
|
83
|
+
export declare function detectAndArchiveOnCommit(adapter?: DatabaseAdapter): Promise<number>;
|
|
84
|
+
/**
|
|
85
|
+
* Detect and transition in_progress tasks to waiting_review based on quality gates
|
|
86
|
+
* Database-backed approach that survives restarts
|
|
87
|
+
*
|
|
88
|
+
* Quality gates:
|
|
89
|
+
* - Task has been idle (no updates) for configured time (default 3 minutes)
|
|
90
|
+
* - All watched files have been modified at least once
|
|
91
|
+
* - TypeScript compiles without errors (if .ts files)
|
|
92
|
+
* - Tests pass (if test files exist)
|
|
93
|
+
*
|
|
94
|
+
* @param db - Database instance
|
|
95
|
+
* @returns Count of transitioned tasks
|
|
96
|
+
*/
|
|
97
|
+
export declare function detectAndTransitionToReview(adapter?: DatabaseAdapter): Promise<number>;
|
|
28
98
|
//# sourceMappingURL=task-stale-detection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-stale-detection.d.ts","sourceRoot":"","sources":["../../src/utils/task-stale-detection.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"task-stale-detection.d.ts","sourceRoot":"","sources":["../../src/utils/task-stale-detection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAiDvD;;;;;;;;GAQG;AACH,wBAAsB,6BAA6B,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAqD9F;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC;IAChF,OAAO,EAAE,OAAO,CAAC;IACjB,wBAAwB,EAAE,MAAM,CAAC;IACjC,2BAA2B,EAAE,MAAM,CAAC;CACrC,CAAC,CAoBD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAkBxF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,8BAA8B,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAqG/F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,0BAA0B,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ3F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAgGzF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,2BAA2B,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ5F"}
|