@jonit-dev/night-watch-cli 1.7.10 → 1.7.11
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/LICENSE +1 -1
- package/dist/commands/dashboard/tab-config.d.ts.map +1 -1
- package/dist/commands/dashboard/tab-config.js +8 -1
- package/dist/commands/dashboard/tab-config.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +3 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/review.d.ts +4 -0
- package/dist/commands/review.d.ts.map +1 -1
- package/dist/commands/review.js +30 -0
- package/dist/commands/review.js.map +1 -1
- package/dist/commands/run.d.ts +11 -0
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +47 -7
- package/dist/commands/run.js.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +43 -3
- package/dist/server/index.js.map +1 -1
- package/dist/shared/types.d.ts +223 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +7 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/src/agents/soul-compiler.d.ts +11 -0
- package/dist/src/agents/soul-compiler.d.ts.map +1 -0
- package/dist/src/agents/soul-compiler.js +103 -0
- package/dist/src/agents/soul-compiler.js.map +1 -0
- package/dist/src/board/factory.d.ts +3 -0
- package/dist/src/board/factory.d.ts.map +1 -0
- package/dist/src/board/factory.js +10 -0
- package/dist/src/board/factory.js.map +1 -0
- package/dist/src/board/providers/github-graphql.d.ts +16 -0
- package/dist/src/board/providers/github-graphql.d.ts.map +1 -0
- package/dist/src/board/providers/github-graphql.js +43 -0
- package/dist/src/board/providers/github-graphql.js.map +1 -0
- package/dist/src/board/providers/github-projects.d.ts +51 -0
- package/dist/src/board/providers/github-projects.d.ts.map +1 -0
- package/dist/src/board/providers/github-projects.js +672 -0
- package/dist/src/board/providers/github-projects.js.map +1 -0
- package/dist/src/board/types.d.ts +60 -0
- package/dist/src/board/types.d.ts.map +1 -0
- package/dist/src/board/types.js +4 -0
- package/dist/src/board/types.js.map +1 -0
- package/dist/src/cli.d.ts +3 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +80 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/board.d.ts +9 -0
- package/dist/src/commands/board.d.ts.map +1 -0
- package/dist/src/commands/board.js +294 -0
- package/dist/src/commands/board.js.map +1 -0
- package/dist/src/commands/cancel.d.ts +46 -0
- package/dist/src/commands/cancel.d.ts.map +1 -0
- package/dist/src/commands/cancel.js +241 -0
- package/dist/src/commands/cancel.js.map +1 -0
- package/dist/src/commands/dashboard/tab-actions.d.ts +10 -0
- package/dist/src/commands/dashboard/tab-actions.d.ts.map +1 -0
- package/dist/src/commands/dashboard/tab-actions.js +245 -0
- package/dist/src/commands/dashboard/tab-actions.js.map +1 -0
- package/dist/src/commands/dashboard/tab-config.d.ts +21 -0
- package/dist/src/commands/dashboard/tab-config.d.ts.map +1 -0
- package/dist/src/commands/dashboard/tab-config.js +829 -0
- package/dist/src/commands/dashboard/tab-config.js.map +1 -0
- package/dist/src/commands/dashboard/tab-logs.d.ts +10 -0
- package/dist/src/commands/dashboard/tab-logs.d.ts.map +1 -0
- package/dist/src/commands/dashboard/tab-logs.js +178 -0
- package/dist/src/commands/dashboard/tab-logs.js.map +1 -0
- package/dist/src/commands/dashboard/tab-schedules.d.ts +21 -0
- package/dist/src/commands/dashboard/tab-schedules.d.ts.map +1 -0
- package/dist/src/commands/dashboard/tab-schedules.js +304 -0
- package/dist/src/commands/dashboard/tab-schedules.js.map +1 -0
- package/dist/src/commands/dashboard/tab-status.d.ts +32 -0
- package/dist/src/commands/dashboard/tab-status.d.ts.map +1 -0
- package/dist/src/commands/dashboard/tab-status.js +421 -0
- package/dist/src/commands/dashboard/tab-status.js.map +1 -0
- package/dist/src/commands/dashboard/types.d.ts +43 -0
- package/dist/src/commands/dashboard/types.d.ts.map +1 -0
- package/dist/src/commands/dashboard/types.js +5 -0
- package/dist/src/commands/dashboard/types.js.map +1 -0
- package/dist/src/commands/dashboard.d.ts +11 -0
- package/dist/src/commands/dashboard.d.ts.map +1 -0
- package/dist/src/commands/dashboard.js +239 -0
- package/dist/src/commands/dashboard.js.map +1 -0
- package/dist/src/commands/doctor.d.ts +16 -0
- package/dist/src/commands/doctor.d.ts.map +1 -0
- package/dist/src/commands/doctor.js +202 -0
- package/dist/src/commands/doctor.js.map +1 -0
- package/dist/src/commands/history.d.ts +7 -0
- package/dist/src/commands/history.d.ts.map +1 -0
- package/dist/src/commands/history.js +56 -0
- package/dist/src/commands/history.js.map +1 -0
- package/dist/src/commands/init.d.ts +25 -0
- package/dist/src/commands/init.d.ts.map +1 -0
- package/dist/src/commands/init.js +543 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/install.d.ts +48 -0
- package/dist/src/commands/install.d.ts.map +1 -0
- package/dist/src/commands/install.js +303 -0
- package/dist/src/commands/install.js.map +1 -0
- package/dist/src/commands/logs.d.ts +15 -0
- package/dist/src/commands/logs.d.ts.map +1 -0
- package/dist/src/commands/logs.js +104 -0
- package/dist/src/commands/logs.js.map +1 -0
- package/dist/src/commands/prd-state.d.ts +12 -0
- package/dist/src/commands/prd-state.d.ts.map +1 -0
- package/dist/src/commands/prd-state.js +47 -0
- package/dist/src/commands/prd-state.js.map +1 -0
- package/dist/src/commands/prd.d.ts +24 -0
- package/dist/src/commands/prd.d.ts.map +1 -0
- package/dist/src/commands/prd.js +283 -0
- package/dist/src/commands/prd.js.map +1 -0
- package/dist/src/commands/prds.d.ts +13 -0
- package/dist/src/commands/prds.d.ts.map +1 -0
- package/dist/src/commands/prds.js +196 -0
- package/dist/src/commands/prds.js.map +1 -0
- package/dist/src/commands/prs.d.ts +14 -0
- package/dist/src/commands/prs.d.ts.map +1 -0
- package/dist/src/commands/prs.js +106 -0
- package/dist/src/commands/prs.js.map +1 -0
- package/dist/src/commands/qa.d.ts +30 -0
- package/dist/src/commands/qa.d.ts.map +1 -0
- package/dist/src/commands/qa.js +159 -0
- package/dist/src/commands/qa.js.map +1 -0
- package/dist/src/commands/retry.d.ts +9 -0
- package/dist/src/commands/retry.d.ts.map +1 -0
- package/dist/src/commands/retry.js +72 -0
- package/dist/src/commands/retry.js.map +1 -0
- package/dist/src/commands/review.d.ts +35 -0
- package/dist/src/commands/review.d.ts.map +1 -0
- package/dist/src/commands/review.js +252 -0
- package/dist/src/commands/review.js.map +1 -0
- package/dist/src/commands/run.d.ts +61 -0
- package/dist/src/commands/run.d.ts.map +1 -0
- package/dist/src/commands/run.js +364 -0
- package/dist/src/commands/run.js.map +1 -0
- package/dist/src/commands/serve.d.ts +7 -0
- package/dist/src/commands/serve.d.ts.map +1 -0
- package/dist/src/commands/serve.js +27 -0
- package/dist/src/commands/serve.js.map +1 -0
- package/dist/src/commands/slice.d.ts +26 -0
- package/dist/src/commands/slice.d.ts.map +1 -0
- package/dist/src/commands/slice.js +175 -0
- package/dist/src/commands/slice.js.map +1 -0
- package/dist/src/commands/state.d.ts +8 -0
- package/dist/src/commands/state.d.ts.map +1 -0
- package/dist/src/commands/state.js +56 -0
- package/dist/src/commands/state.js.map +1 -0
- package/dist/src/commands/status.d.ts +14 -0
- package/dist/src/commands/status.d.ts.map +1 -0
- package/dist/src/commands/status.js +147 -0
- package/dist/src/commands/status.js.map +1 -0
- package/dist/src/commands/uninstall.d.ts +25 -0
- package/dist/src/commands/uninstall.d.ts.map +1 -0
- package/dist/src/commands/uninstall.js +141 -0
- package/dist/src/commands/uninstall.js.map +1 -0
- package/dist/src/commands/update.d.ts +21 -0
- package/dist/src/commands/update.d.ts.map +1 -0
- package/dist/src/commands/update.js +87 -0
- package/dist/src/commands/update.js.map +1 -0
- package/dist/src/config.d.ts +23 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +629 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/constants.d.ts +60 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +118 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/server/index.d.ts +23 -0
- package/dist/src/server/index.d.ts.map +1 -0
- package/dist/src/server/index.js +1642 -0
- package/dist/src/server/index.js.map +1 -0
- package/dist/src/slack/channel-manager.d.ts +32 -0
- package/dist/src/slack/channel-manager.d.ts.map +1 -0
- package/dist/src/slack/channel-manager.js +128 -0
- package/dist/src/slack/channel-manager.js.map +1 -0
- package/dist/src/slack/client.d.ts +63 -0
- package/dist/src/slack/client.d.ts.map +1 -0
- package/dist/src/slack/client.js +151 -0
- package/dist/src/slack/client.js.map +1 -0
- package/dist/src/slack/deliberation.d.ts +45 -0
- package/dist/src/slack/deliberation.d.ts.map +1 -0
- package/dist/src/slack/deliberation.js +539 -0
- package/dist/src/slack/deliberation.js.map +1 -0
- package/dist/src/slack/index.d.ts +6 -0
- package/dist/src/slack/index.d.ts.map +1 -0
- package/dist/src/slack/index.js +5 -0
- package/dist/src/slack/index.js.map +1 -0
- package/dist/src/slack/interaction-listener.d.ts +47 -0
- package/dist/src/slack/interaction-listener.d.ts.map +1 -0
- package/dist/src/slack/interaction-listener.js +216 -0
- package/dist/src/slack/interaction-listener.js.map +1 -0
- package/dist/src/storage/json-state-migrator.d.ts +24 -0
- package/dist/src/storage/json-state-migrator.d.ts.map +1 -0
- package/dist/src/storage/json-state-migrator.js +197 -0
- package/dist/src/storage/json-state-migrator.js.map +1 -0
- package/dist/src/storage/repositories/index.d.ts +25 -0
- package/dist/src/storage/repositories/index.d.ts.map +1 -0
- package/dist/src/storage/repositories/index.js +43 -0
- package/dist/src/storage/repositories/index.js.map +1 -0
- package/dist/src/storage/repositories/interfaces.d.ts +59 -0
- package/dist/src/storage/repositories/interfaces.d.ts.map +1 -0
- package/dist/src/storage/repositories/interfaces.js +6 -0
- package/dist/src/storage/repositories/interfaces.js.map +1 -0
- package/dist/src/storage/repositories/sqlite/agent-persona-repository.d.ts +27 -0
- package/dist/src/storage/repositories/sqlite/agent-persona-repository.d.ts.map +1 -0
- package/dist/src/storage/repositories/sqlite/agent-persona-repository.js +569 -0
- package/dist/src/storage/repositories/sqlite/agent-persona-repository.js.map +1 -0
- package/dist/src/storage/repositories/sqlite/execution-history-repository.d.ts +21 -0
- package/dist/src/storage/repositories/sqlite/execution-history-repository.d.ts.map +1 -0
- package/dist/src/storage/repositories/sqlite/execution-history-repository.js +94 -0
- package/dist/src/storage/repositories/sqlite/execution-history-repository.js.map +1 -0
- package/dist/src/storage/repositories/sqlite/prd-state-repository.d.ts +17 -0
- package/dist/src/storage/repositories/sqlite/prd-state-repository.d.ts.map +1 -0
- package/dist/src/storage/repositories/sqlite/prd-state-repository.js +74 -0
- package/dist/src/storage/repositories/sqlite/prd-state-repository.js.map +1 -0
- package/dist/src/storage/repositories/sqlite/project-registry-repository.d.ts +17 -0
- package/dist/src/storage/repositories/sqlite/project-registry-repository.d.ts.map +1 -0
- package/dist/src/storage/repositories/sqlite/project-registry-repository.js +43 -0
- package/dist/src/storage/repositories/sqlite/project-registry-repository.js.map +1 -0
- package/dist/src/storage/repositories/sqlite/roadmap-state-repository.d.ts +14 -0
- package/dist/src/storage/repositories/sqlite/roadmap-state-repository.d.ts.map +1 -0
- package/dist/src/storage/repositories/sqlite/roadmap-state-repository.js +47 -0
- package/dist/src/storage/repositories/sqlite/roadmap-state-repository.js.map +1 -0
- package/dist/src/storage/repositories/sqlite/slack-discussion-repository.d.ts +20 -0
- package/dist/src/storage/repositories/sqlite/slack-discussion-repository.d.ts.map +1 -0
- package/dist/src/storage/repositories/sqlite/slack-discussion-repository.js +88 -0
- package/dist/src/storage/repositories/sqlite/slack-discussion-repository.js.map +1 -0
- package/dist/src/storage/sqlite/client.d.ts +23 -0
- package/dist/src/storage/sqlite/client.d.ts.map +1 -0
- package/dist/src/storage/sqlite/client.js +47 -0
- package/dist/src/storage/sqlite/client.js.map +1 -0
- package/dist/src/storage/sqlite/migrations.d.ts +11 -0
- package/dist/src/storage/sqlite/migrations.d.ts.map +1 -0
- package/dist/src/storage/sqlite/migrations.js +94 -0
- package/dist/src/storage/sqlite/migrations.js.map +1 -0
- package/dist/src/templates/prd-template.d.ts +11 -0
- package/dist/src/templates/prd-template.d.ts.map +1 -0
- package/dist/src/templates/prd-template.js +166 -0
- package/dist/src/templates/prd-template.js.map +1 -0
- package/dist/src/templates/slicer-prompt.d.ts +54 -0
- package/dist/src/templates/slicer-prompt.d.ts.map +1 -0
- package/dist/src/templates/slicer-prompt.js +163 -0
- package/dist/src/templates/slicer-prompt.js.map +1 -0
- package/dist/src/types.d.ts +127 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +5 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/checks.d.ts +55 -0
- package/dist/src/utils/checks.d.ts.map +1 -0
- package/dist/src/utils/checks.js +246 -0
- package/dist/src/utils/checks.js.map +1 -0
- package/dist/src/utils/config-writer.d.ts +16 -0
- package/dist/src/utils/config-writer.d.ts.map +1 -0
- package/dist/src/utils/config-writer.js +45 -0
- package/dist/src/utils/config-writer.js.map +1 -0
- package/dist/src/utils/crontab.d.ts +62 -0
- package/dist/src/utils/crontab.d.ts.map +1 -0
- package/dist/src/utils/crontab.js +168 -0
- package/dist/src/utils/crontab.js.map +1 -0
- package/dist/src/utils/execution-history.d.ts +54 -0
- package/dist/src/utils/execution-history.d.ts.map +1 -0
- package/dist/src/utils/execution-history.js +80 -0
- package/dist/src/utils/execution-history.js.map +1 -0
- package/dist/src/utils/github.d.ts +40 -0
- package/dist/src/utils/github.d.ts.map +1 -0
- package/dist/src/utils/github.js +126 -0
- package/dist/src/utils/github.js.map +1 -0
- package/dist/src/utils/notify.d.ts +63 -0
- package/dist/src/utils/notify.d.ts.map +1 -0
- package/dist/src/utils/notify.js +389 -0
- package/dist/src/utils/notify.js.map +1 -0
- package/dist/src/utils/prd-states.d.ts +16 -0
- package/dist/src/utils/prd-states.d.ts.map +1 -0
- package/dist/src/utils/prd-states.js +28 -0
- package/dist/src/utils/prd-states.js.map +1 -0
- package/dist/src/utils/registry.d.ts +45 -0
- package/dist/src/utils/registry.d.ts.map +1 -0
- package/dist/src/utils/registry.js +86 -0
- package/dist/src/utils/registry.js.map +1 -0
- package/dist/src/utils/roadmap-parser.d.ts +45 -0
- package/dist/src/utils/roadmap-parser.d.ts.map +1 -0
- package/dist/src/utils/roadmap-parser.js +136 -0
- package/dist/src/utils/roadmap-parser.js.map +1 -0
- package/dist/src/utils/roadmap-scanner.d.ts +92 -0
- package/dist/src/utils/roadmap-scanner.d.ts.map +1 -0
- package/dist/src/utils/roadmap-scanner.js +349 -0
- package/dist/src/utils/roadmap-scanner.js.map +1 -0
- package/dist/src/utils/roadmap-state.d.ts +90 -0
- package/dist/src/utils/roadmap-state.d.ts.map +1 -0
- package/dist/src/utils/roadmap-state.js +154 -0
- package/dist/src/utils/roadmap-state.js.map +1 -0
- package/dist/src/utils/script-result.d.ts +12 -0
- package/dist/src/utils/script-result.d.ts.map +1 -0
- package/dist/src/utils/script-result.js +46 -0
- package/dist/src/utils/script-result.js.map +1 -0
- package/dist/src/utils/shell.d.ts +27 -0
- package/dist/src/utils/shell.d.ts.map +1 -0
- package/dist/src/utils/shell.js +64 -0
- package/dist/src/utils/shell.js.map +1 -0
- package/dist/src/utils/status-data.d.ts +148 -0
- package/dist/src/utils/status-data.d.ts.map +1 -0
- package/dist/src/utils/status-data.js +593 -0
- package/dist/src/utils/status-data.js.map +1 -0
- package/dist/src/utils/ui.d.ts +55 -0
- package/dist/src/utils/ui.d.ts.map +1 -0
- package/dist/src/utils/ui.js +121 -0
- package/dist/src/utils/ui.js.map +1 -0
- package/package.json +3 -1
- package/scripts/night-watch-cron.sh +7 -0
- package/scripts/night-watch-helpers.sh +33 -4
- package/scripts/night-watch-pr-reviewer-cron.sh +11 -3
- package/web/dist/assets/index-BtxQU4oX.css +1 -0
- package/web/dist/assets/index-CsNIryJz.js +473 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-BPW-7_1C.js +0 -380
- package/web/dist/assets/index-DVqjjJEO.css +0 -1
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dashboard command for Night Watch CLI
|
|
3
|
+
* Tabbed TUI with Status, Config, Schedules, Actions, and Logs tabs
|
|
4
|
+
*/
|
|
5
|
+
import blessed from "blessed";
|
|
6
|
+
import { loadConfig } from "../config.js";
|
|
7
|
+
import { fetchStatusSnapshot } from "../utils/status-data.js";
|
|
8
|
+
import { createStatusTab } from "./dashboard/tab-status.js";
|
|
9
|
+
import { createConfigTab } from "./dashboard/tab-config.js";
|
|
10
|
+
import { createSchedulesTab } from "./dashboard/tab-schedules.js";
|
|
11
|
+
import { createActionsTab } from "./dashboard/tab-actions.js";
|
|
12
|
+
import { createLogsTab } from "./dashboard/tab-logs.js";
|
|
13
|
+
// Re-export render functions for backward compatibility (used by tests)
|
|
14
|
+
export { renderPrdPane, renderProcessPane, renderPrPane, renderLogPane, } from "./dashboard/tab-status.js";
|
|
15
|
+
/**
|
|
16
|
+
* Show a temporary flash message overlay
|
|
17
|
+
*/
|
|
18
|
+
function showMessage(screen, text, type, durationMs = 2000) {
|
|
19
|
+
const colors = { success: "green", error: "red", info: "cyan" };
|
|
20
|
+
const msgBox = blessed.box({
|
|
21
|
+
top: "center",
|
|
22
|
+
left: "center",
|
|
23
|
+
width: Math.min(60, text.length + 6),
|
|
24
|
+
height: 3,
|
|
25
|
+
content: `{center}${text}{/center}`,
|
|
26
|
+
tags: true,
|
|
27
|
+
border: { type: "line" },
|
|
28
|
+
style: { border: { fg: colors[type] }, fg: "white", bg: "black" },
|
|
29
|
+
});
|
|
30
|
+
screen.append(msgBox);
|
|
31
|
+
screen.render();
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
msgBox.destroy();
|
|
34
|
+
screen.render();
|
|
35
|
+
}, durationMs);
|
|
36
|
+
}
|
|
37
|
+
export function dashboardCommand(program) {
|
|
38
|
+
program
|
|
39
|
+
.command("dashboard")
|
|
40
|
+
.description("Live terminal dashboard")
|
|
41
|
+
.option("--interval <seconds>", "Refresh interval in seconds", "10")
|
|
42
|
+
.action(async (options) => {
|
|
43
|
+
const projectDir = process.cwd();
|
|
44
|
+
let config = loadConfig(projectDir);
|
|
45
|
+
// Create blessed screen
|
|
46
|
+
const screen = blessed.screen({
|
|
47
|
+
smartCSR: true,
|
|
48
|
+
title: "Night Watch Dashboard",
|
|
49
|
+
fullUnicode: true,
|
|
50
|
+
});
|
|
51
|
+
// --- Layout ---
|
|
52
|
+
// Header: row 0, height 1
|
|
53
|
+
const headerBox = blessed.box({
|
|
54
|
+
top: 0,
|
|
55
|
+
left: 0,
|
|
56
|
+
width: "100%",
|
|
57
|
+
height: 1,
|
|
58
|
+
content: "{center}Night Watch Dashboard{/center}",
|
|
59
|
+
tags: true,
|
|
60
|
+
style: { fg: "cyan", bold: true },
|
|
61
|
+
});
|
|
62
|
+
// Tab bar: row 1, height 1
|
|
63
|
+
const tabBar = blessed.box({
|
|
64
|
+
top: 1,
|
|
65
|
+
left: 0,
|
|
66
|
+
width: "100%",
|
|
67
|
+
height: 1,
|
|
68
|
+
tags: true,
|
|
69
|
+
style: { fg: "white", bg: "black" },
|
|
70
|
+
content: "",
|
|
71
|
+
});
|
|
72
|
+
// Content area: rows 2..n-2
|
|
73
|
+
const contentArea = blessed.box({
|
|
74
|
+
top: 2,
|
|
75
|
+
left: 0,
|
|
76
|
+
width: "100%",
|
|
77
|
+
height: "100%-4",
|
|
78
|
+
});
|
|
79
|
+
// Footer: bottom row
|
|
80
|
+
const footerBox = blessed.box({
|
|
81
|
+
bottom: 0,
|
|
82
|
+
left: 0,
|
|
83
|
+
width: "100%",
|
|
84
|
+
height: 1,
|
|
85
|
+
content: "",
|
|
86
|
+
tags: true,
|
|
87
|
+
style: { fg: "white", bg: "blue" },
|
|
88
|
+
});
|
|
89
|
+
screen.append(headerBox);
|
|
90
|
+
screen.append(tabBar);
|
|
91
|
+
screen.append(contentArea);
|
|
92
|
+
screen.append(footerBox);
|
|
93
|
+
// --- Create tabs ---
|
|
94
|
+
const tabs = [
|
|
95
|
+
createStatusTab(),
|
|
96
|
+
createConfigTab(),
|
|
97
|
+
createSchedulesTab(),
|
|
98
|
+
createActionsTab(),
|
|
99
|
+
createLogsTab(),
|
|
100
|
+
];
|
|
101
|
+
// Append all tab containers to content area
|
|
102
|
+
for (const tab of tabs) {
|
|
103
|
+
contentArea.append(tab.container);
|
|
104
|
+
}
|
|
105
|
+
// --- State ---
|
|
106
|
+
let activeTabIndex = 0;
|
|
107
|
+
let isEditing = false;
|
|
108
|
+
let snapshot = fetchStatusSnapshot(projectDir, config);
|
|
109
|
+
// --- Tab context ---
|
|
110
|
+
const ctx = {
|
|
111
|
+
screen,
|
|
112
|
+
projectDir,
|
|
113
|
+
config,
|
|
114
|
+
snapshot,
|
|
115
|
+
reloadConfig: () => {
|
|
116
|
+
config = loadConfig(projectDir);
|
|
117
|
+
ctx.config = config;
|
|
118
|
+
return config;
|
|
119
|
+
},
|
|
120
|
+
refreshSnapshot: () => {
|
|
121
|
+
snapshot = fetchStatusSnapshot(projectDir, config);
|
|
122
|
+
ctx.snapshot = snapshot;
|
|
123
|
+
return snapshot;
|
|
124
|
+
},
|
|
125
|
+
setFooter: (text) => {
|
|
126
|
+
footerBox.setContent(text);
|
|
127
|
+
},
|
|
128
|
+
showMessage: (text, type, durationMs) => {
|
|
129
|
+
showMessage(screen, text, type, durationMs);
|
|
130
|
+
},
|
|
131
|
+
setEditing: (editing) => {
|
|
132
|
+
isEditing = editing;
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
// --- Tab bar rendering ---
|
|
136
|
+
function renderTabBar() {
|
|
137
|
+
const parts = tabs.map((tab, idx) => {
|
|
138
|
+
const num = idx + 1;
|
|
139
|
+
if (idx === activeTabIndex) {
|
|
140
|
+
return `{white-bg}{black-fg} ${num}:${tab.name} {/black-fg}{/white-bg}`;
|
|
141
|
+
}
|
|
142
|
+
return ` {blue-fg}${num}:${tab.name}{/blue-fg} `;
|
|
143
|
+
});
|
|
144
|
+
tabBar.setContent(parts.join(""));
|
|
145
|
+
}
|
|
146
|
+
// --- Tab switching ---
|
|
147
|
+
function switchTab(newIndex) {
|
|
148
|
+
if (newIndex === activeTabIndex)
|
|
149
|
+
return;
|
|
150
|
+
if (newIndex < 0 || newIndex >= tabs.length)
|
|
151
|
+
return;
|
|
152
|
+
if (isEditing)
|
|
153
|
+
return; // Don't switch while editing
|
|
154
|
+
// Deactivate current tab
|
|
155
|
+
tabs[activeTabIndex].deactivate();
|
|
156
|
+
tabs[activeTabIndex].container.hide();
|
|
157
|
+
// Activate new tab
|
|
158
|
+
activeTabIndex = newIndex;
|
|
159
|
+
tabs[activeTabIndex].container.show();
|
|
160
|
+
renderTabBar();
|
|
161
|
+
tabs[activeTabIndex].activate(ctx);
|
|
162
|
+
screen.render();
|
|
163
|
+
}
|
|
164
|
+
// --- Header ---
|
|
165
|
+
const intervalSeconds = parseInt(options.interval, 10) || 10;
|
|
166
|
+
let countdown = intervalSeconds;
|
|
167
|
+
function updateHeader() {
|
|
168
|
+
headerBox.setContent(`{center}Night Watch: ${snapshot.projectName} | Provider: ${config.provider} | Last: ${snapshot.timestamp.toLocaleTimeString()} | Next: ${countdown}s{/center}`);
|
|
169
|
+
}
|
|
170
|
+
// --- Refresh ---
|
|
171
|
+
function refreshData() {
|
|
172
|
+
config = loadConfig(projectDir);
|
|
173
|
+
ctx.config = config;
|
|
174
|
+
snapshot = fetchStatusSnapshot(projectDir, config);
|
|
175
|
+
ctx.snapshot = snapshot;
|
|
176
|
+
countdown = intervalSeconds;
|
|
177
|
+
updateHeader();
|
|
178
|
+
tabs[activeTabIndex].refresh(ctx);
|
|
179
|
+
screen.render();
|
|
180
|
+
}
|
|
181
|
+
// --- Timer ---
|
|
182
|
+
const timer = setInterval(() => {
|
|
183
|
+
countdown--;
|
|
184
|
+
updateHeader();
|
|
185
|
+
screen.render();
|
|
186
|
+
if (countdown <= 0) {
|
|
187
|
+
refreshData();
|
|
188
|
+
}
|
|
189
|
+
}, 1000);
|
|
190
|
+
// --- Global keyboard handlers ---
|
|
191
|
+
screen.key(["q", "escape"], () => {
|
|
192
|
+
if (isEditing)
|
|
193
|
+
return;
|
|
194
|
+
clearInterval(timer);
|
|
195
|
+
for (const tab of tabs) {
|
|
196
|
+
tab.destroy();
|
|
197
|
+
}
|
|
198
|
+
screen.destroy();
|
|
199
|
+
process.exit(0);
|
|
200
|
+
});
|
|
201
|
+
screen.key(["r"], () => {
|
|
202
|
+
if (isEditing)
|
|
203
|
+
return;
|
|
204
|
+
refreshData();
|
|
205
|
+
});
|
|
206
|
+
// Tab switching via number keys
|
|
207
|
+
for (let i = 0; i < tabs.length; i++) {
|
|
208
|
+
const idx = i;
|
|
209
|
+
screen.key([String(i + 1)], () => {
|
|
210
|
+
if (isEditing)
|
|
211
|
+
return;
|
|
212
|
+
switchTab(idx);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
// Tab cycling is handled per-tab (Status tab uses Tab for pane focus)
|
|
216
|
+
// Shift+Tab always cycles tabs
|
|
217
|
+
screen.key(["S-tab"], () => {
|
|
218
|
+
if (isEditing)
|
|
219
|
+
return;
|
|
220
|
+
const newIndex = (activeTabIndex - 1 + tabs.length) % tabs.length;
|
|
221
|
+
switchTab(newIndex);
|
|
222
|
+
});
|
|
223
|
+
// --- Initial render ---
|
|
224
|
+
// Show only the first tab's container
|
|
225
|
+
for (let i = 0; i < tabs.length; i++) {
|
|
226
|
+
if (i === 0) {
|
|
227
|
+
tabs[i].container.show();
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
tabs[i].container.hide();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
renderTabBar();
|
|
234
|
+
updateHeader();
|
|
235
|
+
tabs[activeTabIndex].activate(ctx);
|
|
236
|
+
screen.render();
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=dashboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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ED,sEAAsE;QACtE,+BAA+B;QAC/B,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE;YACzB,IAAI,SAAS;gBAAE,OAAO;YACtB,MAAM,QAAQ,GAAG,CAAC,cAAc,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;YAClE,SAAS,CAAC,QAAQ,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;QAEH,yBAAyB;QACzB,sCAAsC;QACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBACZ,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YAC3B,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YAC3B,CAAC;QACH,CAAC;QAED,YAAY,EAAE,CAAC;QACf,YAAY,EAAE,CAAC;QACf,IAAI,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,CAAC,MAAM,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Doctor command for Night Watch CLI
|
|
3
|
+
* Validates environment setup and system health
|
|
4
|
+
*/
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
import { IWebhookConfig } from "../types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Validate a single webhook configuration and return a list of issues.
|
|
9
|
+
* Returns an empty array if the webhook is valid.
|
|
10
|
+
*/
|
|
11
|
+
export declare function validateWebhook(webhook: IWebhookConfig): string[];
|
|
12
|
+
/**
|
|
13
|
+
* Register the doctor command on the program
|
|
14
|
+
*/
|
|
15
|
+
export declare function doctorCommand(program: Command): void;
|
|
16
|
+
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAqB,MAAM,aAAa,CAAC;AAsBhE;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,EAAE,CAuDjE;AAiDD;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA+IpD"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Doctor command for Night Watch CLI
|
|
3
|
+
* Validates environment setup and system health
|
|
4
|
+
*/
|
|
5
|
+
import { loadConfig } from "../config.js";
|
|
6
|
+
import { header, info, label, step, success, error as uiError, warn, } from "../utils/ui.js";
|
|
7
|
+
import { checkConfigFile, checkCrontabAccess, checkGhCli, checkGitRepo, checkLogsDirectory, checkNodeVersion, checkPrdDirectory, checkProviderCli, } from "../utils/checks.js";
|
|
8
|
+
/**
|
|
9
|
+
* Validate a single webhook configuration and return a list of issues.
|
|
10
|
+
* Returns an empty array if the webhook is valid.
|
|
11
|
+
*/
|
|
12
|
+
export function validateWebhook(webhook) {
|
|
13
|
+
const issues = [];
|
|
14
|
+
// Validate events
|
|
15
|
+
if (!webhook.events || webhook.events.length === 0) {
|
|
16
|
+
issues.push("No events configured");
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
const validEvents = [
|
|
20
|
+
"run_started",
|
|
21
|
+
"run_succeeded",
|
|
22
|
+
"run_failed",
|
|
23
|
+
"run_timeout",
|
|
24
|
+
"review_completed",
|
|
25
|
+
"pr_auto_merged",
|
|
26
|
+
"rate_limit_fallback",
|
|
27
|
+
"qa_completed",
|
|
28
|
+
];
|
|
29
|
+
for (const event of webhook.events) {
|
|
30
|
+
if (!validEvents.includes(event)) {
|
|
31
|
+
issues.push(`Invalid event: ${event}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Platform-specific validation
|
|
36
|
+
switch (webhook.type) {
|
|
37
|
+
case "slack":
|
|
38
|
+
if (!webhook.url) {
|
|
39
|
+
issues.push("Missing URL");
|
|
40
|
+
}
|
|
41
|
+
else if (!webhook.url.startsWith("https://hooks.slack.com/")) {
|
|
42
|
+
issues.push("URL should start with https://hooks.slack.com/");
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
case "discord":
|
|
46
|
+
if (!webhook.url) {
|
|
47
|
+
issues.push("Missing URL");
|
|
48
|
+
}
|
|
49
|
+
else if (!webhook.url.startsWith("https://discord.com/api/webhooks/")) {
|
|
50
|
+
issues.push("URL should start with https://discord.com/api/webhooks/");
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
case "telegram":
|
|
54
|
+
if (!webhook.botToken) {
|
|
55
|
+
issues.push("Missing botToken");
|
|
56
|
+
}
|
|
57
|
+
if (!webhook.chatId) {
|
|
58
|
+
issues.push("Missing chatId");
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
issues.push(`Unknown webhook type: ${webhook.type}`);
|
|
63
|
+
}
|
|
64
|
+
return issues;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Run a single check and print the result
|
|
68
|
+
*/
|
|
69
|
+
function runCheck(checkNum, total, checkName, checkFn, options) {
|
|
70
|
+
step(checkNum, total, `Checking ${checkName}...`);
|
|
71
|
+
const result = checkFn();
|
|
72
|
+
if (result.passed) {
|
|
73
|
+
success(result.message);
|
|
74
|
+
return { passed: true, fixed: false };
|
|
75
|
+
}
|
|
76
|
+
// Check failed
|
|
77
|
+
if (options.fix && result.fixable && result.fix) {
|
|
78
|
+
result.fix();
|
|
79
|
+
// Re-run check after fix
|
|
80
|
+
const recheckResult = checkFn();
|
|
81
|
+
if (recheckResult.passed) {
|
|
82
|
+
success(`Fixed: ${checkName}`);
|
|
83
|
+
return { passed: true, fixed: true };
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
uiError(`Failed to fix: ${checkName}`);
|
|
87
|
+
return { passed: false, fixed: false };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (result.fixable) {
|
|
91
|
+
warn(`${result.message} (run with --fix to auto-fix)`);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
uiError(result.message);
|
|
95
|
+
}
|
|
96
|
+
return { passed: false, fixed: false };
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Register the doctor command on the program
|
|
100
|
+
*/
|
|
101
|
+
export function doctorCommand(program) {
|
|
102
|
+
program
|
|
103
|
+
.command("doctor")
|
|
104
|
+
.description("Check Night Watch configuration and system health")
|
|
105
|
+
.option("--fix", "Automatically fix fixable issues")
|
|
106
|
+
.action(async (options) => {
|
|
107
|
+
const projectDir = process.cwd();
|
|
108
|
+
const config = loadConfig(projectDir);
|
|
109
|
+
const totalChecks = 8;
|
|
110
|
+
let checkNum = 1;
|
|
111
|
+
let passedChecks = 0;
|
|
112
|
+
let fixedChecks = 0;
|
|
113
|
+
header("Night Watch Doctor");
|
|
114
|
+
// Check 1: Node.js version
|
|
115
|
+
const nodeResult = runCheck(checkNum++, totalChecks, "Node.js version", () => checkNodeVersion(18), options);
|
|
116
|
+
if (nodeResult.passed)
|
|
117
|
+
passedChecks++;
|
|
118
|
+
if (nodeResult.fixed)
|
|
119
|
+
fixedChecks++;
|
|
120
|
+
// Check 2: Git repository
|
|
121
|
+
const gitResult = runCheck(checkNum++, totalChecks, "git repository", () => checkGitRepo(projectDir), options);
|
|
122
|
+
if (gitResult.passed)
|
|
123
|
+
passedChecks++;
|
|
124
|
+
if (gitResult.fixed)
|
|
125
|
+
fixedChecks++;
|
|
126
|
+
// Check 3: GitHub CLI
|
|
127
|
+
const ghResult = runCheck(checkNum++, totalChecks, "GitHub CLI", () => checkGhCli(), options);
|
|
128
|
+
if (ghResult.passed)
|
|
129
|
+
passedChecks++;
|
|
130
|
+
if (ghResult.fixed)
|
|
131
|
+
fixedChecks++;
|
|
132
|
+
// Check 4: Provider CLI
|
|
133
|
+
const providerResult = runCheck(checkNum++, totalChecks, "provider CLI", () => checkProviderCli(config.provider), options);
|
|
134
|
+
if (providerResult.passed)
|
|
135
|
+
passedChecks++;
|
|
136
|
+
if (providerResult.fixed)
|
|
137
|
+
fixedChecks++;
|
|
138
|
+
// Check 5: Config file
|
|
139
|
+
const configResult = runCheck(checkNum++, totalChecks, "config file", () => checkConfigFile(projectDir), options);
|
|
140
|
+
if (configResult.passed)
|
|
141
|
+
passedChecks++;
|
|
142
|
+
if (configResult.fixed)
|
|
143
|
+
fixedChecks++;
|
|
144
|
+
// Check 6: PRD directory
|
|
145
|
+
const prdResult = runCheck(checkNum++, totalChecks, "PRD directory", () => checkPrdDirectory(projectDir, config.prdDir), options);
|
|
146
|
+
if (prdResult.passed)
|
|
147
|
+
passedChecks++;
|
|
148
|
+
if (prdResult.fixed)
|
|
149
|
+
fixedChecks++;
|
|
150
|
+
// Check 7: Logs directory
|
|
151
|
+
const logsResult = runCheck(checkNum++, totalChecks, "logs directory", () => checkLogsDirectory(projectDir), options);
|
|
152
|
+
if (logsResult.passed)
|
|
153
|
+
passedChecks++;
|
|
154
|
+
if (logsResult.fixed)
|
|
155
|
+
fixedChecks++;
|
|
156
|
+
// Check 8: Webhook configuration
|
|
157
|
+
step(checkNum, totalChecks, "Checking webhook configuration...");
|
|
158
|
+
if (!config.notifications ||
|
|
159
|
+
config.notifications.webhooks.length === 0) {
|
|
160
|
+
info("No webhooks configured (optional)");
|
|
161
|
+
passedChecks++;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
let webhookErrors = 0;
|
|
165
|
+
for (const webhook of config.notifications.webhooks) {
|
|
166
|
+
const issues = validateWebhook(webhook);
|
|
167
|
+
if (issues.length === 0) {
|
|
168
|
+
success(`${webhook.type} webhook: OK`);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
for (const issue of issues) {
|
|
172
|
+
warn(`${webhook.type} webhook: ${issue}`);
|
|
173
|
+
}
|
|
174
|
+
webhookErrors++;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (webhookErrors === 0) {
|
|
178
|
+
success(`All ${config.notifications.webhooks.length} webhook(s) valid`);
|
|
179
|
+
passedChecks++;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Check crontab access (non-blocking, informational only)
|
|
183
|
+
const crontabResult = checkCrontabAccess();
|
|
184
|
+
info(crontabResult.message);
|
|
185
|
+
// Summary
|
|
186
|
+
console.log();
|
|
187
|
+
header("Summary");
|
|
188
|
+
label("Checks passed", `${passedChecks}/${totalChecks}`);
|
|
189
|
+
if (fixedChecks > 0) {
|
|
190
|
+
label("Issues fixed", `${fixedChecks}`);
|
|
191
|
+
}
|
|
192
|
+
console.log();
|
|
193
|
+
if (passedChecks === totalChecks) {
|
|
194
|
+
success("All checks passed");
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
uiError("Issues found — fix errors above before running Night Watch");
|
|
198
|
+
process.exit(1);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EACL,MAAM,EACN,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,OAAO,EACP,KAAK,IAAI,OAAO,EAChB,IAAI,GACL,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,UAAU,E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AO,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,mBAAmB,CAC/D,CAAC;gBACF,YAAY,EAAE,CAAC;YACjB,CAAC;QACH,CAAC;QAED,0DAA0D;QAC1D,MAAM,aAAa,GAAG,kBAAkB,EAAE,CAAC;QAC3C,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAE5B,UAAU;QACV,OAAO,CAAC,GAAG,EAAE,CAAC;QACd,MAAM,CAAC,SAAS,CAAC,CAAC;QAClB,KAAK,CAAC,eAAe,EAAE,GAAG,YAAY,IAAI,WAAW,EAAE,CAAC,CAAC;QACzD,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;YACpB,KAAK,CAAC,cAAc,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,CAAC;QAEd,IAAI,YAAY,KAAK,WAAW,EAAE,CAAC;YACjC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,OAAO,CACL,4DAA4D,CAC7D,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* History command — CLI interface to the execution history ledger.
|
|
3
|
+
* Designed for bash script integration (silent stdout, exit-code signaling).
|
|
4
|
+
*/
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
export declare function historyCommand(program: Command): void;
|
|
7
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../src/commands/history.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyErD"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* History command — CLI interface to the execution history ledger.
|
|
3
|
+
* Designed for bash script integration (silent stdout, exit-code signaling).
|
|
4
|
+
*/
|
|
5
|
+
import { isInCooldown, recordExecution, } from "../utils/execution-history.js";
|
|
6
|
+
const VALID_OUTCOMES = [
|
|
7
|
+
"success",
|
|
8
|
+
"failure",
|
|
9
|
+
"timeout",
|
|
10
|
+
"rate_limited",
|
|
11
|
+
];
|
|
12
|
+
export function historyCommand(program) {
|
|
13
|
+
const history = program
|
|
14
|
+
.command("history")
|
|
15
|
+
.description("Manage PRD execution history ledger");
|
|
16
|
+
history
|
|
17
|
+
.command("record <projectDir> <prdFile> <outcome>")
|
|
18
|
+
.description("Record a PRD execution result")
|
|
19
|
+
.option("--exit-code <n>", "Process exit code", "0")
|
|
20
|
+
.option("--attempt <n>", "Attempt number", "1")
|
|
21
|
+
.action((projectDir, prdFile, outcome, options) => {
|
|
22
|
+
if (!VALID_OUTCOMES.includes(outcome)) {
|
|
23
|
+
process.stderr.write(`Invalid outcome: ${outcome}. Must be one of: ${VALID_OUTCOMES.join(", ")}\n`);
|
|
24
|
+
process.exit(2);
|
|
25
|
+
}
|
|
26
|
+
const exitCode = parseInt(options.exitCode, 10);
|
|
27
|
+
const attempt = parseInt(options.attempt, 10);
|
|
28
|
+
if (isNaN(exitCode)) {
|
|
29
|
+
process.stderr.write(`Invalid exit code: ${options.exitCode}\n`);
|
|
30
|
+
process.exit(2);
|
|
31
|
+
}
|
|
32
|
+
if (isNaN(attempt) || attempt < 1) {
|
|
33
|
+
process.stderr.write(`Invalid attempt: ${options.attempt}\n`);
|
|
34
|
+
process.exit(2);
|
|
35
|
+
}
|
|
36
|
+
recordExecution(projectDir, prdFile, outcome, exitCode, attempt);
|
|
37
|
+
});
|
|
38
|
+
history
|
|
39
|
+
.command("check <projectDir> <prdFile>")
|
|
40
|
+
.description("Check if a PRD is in cooldown (exit 0 = in cooldown, exit 1 = eligible)")
|
|
41
|
+
.option("--cooldown <seconds>", "Cooldown period in seconds", "7200")
|
|
42
|
+
.action((projectDir, prdFile, options) => {
|
|
43
|
+
const cooldownPeriod = parseInt(options.cooldown, 10);
|
|
44
|
+
if (isNaN(cooldownPeriod) || cooldownPeriod < 0) {
|
|
45
|
+
process.stderr.write(`Invalid cooldown period: ${options.cooldown}\n`);
|
|
46
|
+
process.exit(2);
|
|
47
|
+
}
|
|
48
|
+
if (isInCooldown(projectDir, prdFile, cooldownPeriod)) {
|
|
49
|
+
process.exit(0); // in cooldown — caller should skip
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
process.exit(1); // eligible — caller should proceed
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../../src/commands/history.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEL,YAAY,EACZ,eAAe,GAChB,MAAM,+BAA+B,CAAC;AAEvC,MAAM,cAAc,GAAuB;IACzC,SAAS;IACT,SAAS;IACT,SAAS;IACT,cAAc;CACf,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,MAAM,OAAO,GAAG,OAAO;SACpB,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,qCAAqC,CAAC,CAAC;IAEtD,OAAO;SACJ,OAAO,CAAC,yCAAyC,CAAC;SAClD,WAAW,CAAC,+BAA+B,CAAC;SAC5C,MAAM,CAAC,iBAAiB,EAAE,mBAAmB,EAAE,GAAG,CAAC;SACnD,MAAM,CAAC,eAAe,EAAE,gBAAgB,EAAE,GAAG,CAAC;SAC9C,MAAM,CACL,CACE,UAAkB,EAClB,OAAe,EACf,OAAe,EACf,OAA8C,EAC9C,EAAE;QACF,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,OAA2B,CAAC,EAAE,CAAC;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,MAAM,CAAC,KAAK,CAClB,4BAA4B,OAAO,CAAC,QAAQ,IAAI,CACjD,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,IAAI,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,cAAc,CAAC,EAAE,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,mCAAmC;QACtD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,mCAAmC;QACtD,CAAC;IACH,CAAC,CACF,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
/**
|
|
4
|
+
* Get the default branch name for the repository
|
|
5
|
+
*/
|
|
6
|
+
export declare function getDefaultBranch(cwd: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Result of template path resolution
|
|
9
|
+
*/
|
|
10
|
+
interface ITemplateResolution {
|
|
11
|
+
path: string;
|
|
12
|
+
source: "custom" | "bundled";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolve a template path with per-file fallback.
|
|
16
|
+
* If customTemplatesDir is non-null and the file exists there, return custom path.
|
|
17
|
+
* Otherwise return the bundled template path.
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveTemplatePath(templateName: string, customTemplatesDir: string | null, bundledTemplatesDir: string): ITemplateResolution;
|
|
20
|
+
/**
|
|
21
|
+
* Main init command implementation
|
|
22
|
+
*/
|
|
23
|
+
export declare function initCommand(program: Command): void;
|
|
24
|
+
export default initCommand;
|
|
25
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA+IpC;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiEpD;AA6CD;;GAEG;AACH,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,kBAAkB,EAAE,MAAM,GAAG,IAAI,EACjC,mBAAmB,EAAE,MAAM,GAC1B,mBAAmB,CAQrB;AAsFD;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAqUlD;AAED,eAAe,WAAW,CAAC"}
|