@basou/cli 0.68.4 → 0.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +109 -114
- package/dist/index.js.map +1 -1
- package/dist/program.js +109 -114
- package/dist/program.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2958,7 +2958,6 @@ async function doRunChannelClear(face, options) {
|
|
|
2958
2958
|
}
|
|
2959
2959
|
|
|
2960
2960
|
// src/commands/decision.ts
|
|
2961
|
-
import { readFile as readFile3 } from "fs/promises";
|
|
2962
2961
|
import { homedir as homedir3 } from "os";
|
|
2963
2962
|
import { join as join7, resolve as resolve4 } from "path";
|
|
2964
2963
|
import {
|
|
@@ -2971,7 +2970,7 @@ import {
|
|
|
2971
2970
|
createAdHocSessionWithEvent,
|
|
2972
2971
|
displayPath as displayPath4,
|
|
2973
2972
|
EVENT_SCHEMA_VERSION as EVENT_SCHEMA_VERSION2,
|
|
2974
|
-
findErrorCode as
|
|
2973
|
+
findErrorCode as findErrorCode5,
|
|
2975
2974
|
isValidPrefixedId,
|
|
2976
2975
|
LOCAL_CLI_EVENT_SOURCE as LOCAL_CLI_EVENT_SOURCE2,
|
|
2977
2976
|
loadSessionEntries,
|
|
@@ -2983,6 +2982,35 @@ import {
|
|
|
2983
2982
|
} from "@basou/core";
|
|
2984
2983
|
import { InvalidArgumentError as InvalidArgumentError2 } from "commander";
|
|
2985
2984
|
|
|
2985
|
+
// src/lib/input-file.ts
|
|
2986
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
2987
|
+
import { findErrorCode as findErrorCode4 } from "@basou/core";
|
|
2988
|
+
function refuseDashInputFile(flag, value, alternative) {
|
|
2989
|
+
if (value !== "-") return;
|
|
2990
|
+
if (alternative === "stdin") {
|
|
2991
|
+
throw new Error(
|
|
2992
|
+
`${flag} - is refused: - is reserved for standard input. Omit ${flag} to read stdin, or pass ${flag} ./- to read a file named -.`
|
|
2993
|
+
);
|
|
2994
|
+
}
|
|
2995
|
+
const toFile = "textFlag" in alternative ? `Write the text to a file and pass ${flag} <path>, or pass it with ${alternative.textFlag}` : `Write ${alternative.fileOnly} to a file and pass its path with ${flag}`;
|
|
2996
|
+
throw new Error(
|
|
2997
|
+
`${flag} - is refused: - is reserved for standard input, which this command does not read. ${toFile}; a file named - is read with ${flag} ./-.`
|
|
2998
|
+
);
|
|
2999
|
+
}
|
|
3000
|
+
async function readInputFileText(flag, path) {
|
|
3001
|
+
try {
|
|
3002
|
+
return await readFile3(path, "utf8");
|
|
3003
|
+
} catch (error) {
|
|
3004
|
+
if (findErrorCode4(error, "ENOENT")) {
|
|
3005
|
+
throw new Error(`${flag} names a file that does not exist`, { cause: error });
|
|
3006
|
+
}
|
|
3007
|
+
if (findErrorCode4(error, "EISDIR")) {
|
|
3008
|
+
throw new Error(`${flag} names a directory, not a file`, { cause: error });
|
|
3009
|
+
}
|
|
3010
|
+
throw new Error(`Could not read the file ${flag} names`, { cause: error });
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
|
|
2986
3014
|
// src/commands/decision-gaps.ts
|
|
2987
3015
|
import {
|
|
2988
3016
|
basouPaths as basouPaths5,
|
|
@@ -3350,6 +3378,7 @@ async function runDecisionCapture(options, ctx = {}) {
|
|
|
3350
3378
|
}
|
|
3351
3379
|
}
|
|
3352
3380
|
async function doRunDecisionCapture(options, ctx) {
|
|
3381
|
+
refuseDashInputFile("--file", options.file, "stdin");
|
|
3353
3382
|
const cwd = ctx.cwd ?? process.cwd();
|
|
3354
3383
|
const repositoryRoot = await resolveBasouRootForCommand(cwd, "decision capture");
|
|
3355
3384
|
const paths = basouPaths6(repositoryRoot);
|
|
@@ -3565,14 +3594,7 @@ function parseReason(raw) {
|
|
|
3565
3594
|
}
|
|
3566
3595
|
async function readCaptureInput(options, ctx) {
|
|
3567
3596
|
if (options.file !== void 0) {
|
|
3568
|
-
|
|
3569
|
-
return await readFile3(options.file, "utf8");
|
|
3570
|
-
} catch (error) {
|
|
3571
|
-
if (findErrorCode4(error, "ENOENT")) {
|
|
3572
|
-
throw new Error(`Input file not found: ${options.file}`);
|
|
3573
|
-
}
|
|
3574
|
-
throw error;
|
|
3575
|
-
}
|
|
3597
|
+
return await readInputFileText("--file", options.file);
|
|
3576
3598
|
}
|
|
3577
3599
|
if (ctx.readInput !== void 0) {
|
|
3578
3600
|
return await ctx.readInput();
|
|
@@ -3911,7 +3933,7 @@ async function assertWorkspaceInitialized4(basouRoot) {
|
|
|
3911
3933
|
try {
|
|
3912
3934
|
await assertBasouRootSafe4(basouRoot);
|
|
3913
3935
|
} catch (error) {
|
|
3914
|
-
if (
|
|
3936
|
+
if (findErrorCode5(error, "ENOENT")) {
|
|
3915
3937
|
throw new Error("Workspace not initialized. Run 'basou init' first.");
|
|
3916
3938
|
}
|
|
3917
3939
|
throw error;
|
|
@@ -3922,7 +3944,7 @@ async function assertWorkspaceInitialized4(basouRoot) {
|
|
|
3922
3944
|
import {
|
|
3923
3945
|
assertBasouRootSafe as assertBasouRootSafe5,
|
|
3924
3946
|
basouPaths as basouPaths7,
|
|
3925
|
-
findErrorCode as
|
|
3947
|
+
findErrorCode as findErrorCode6,
|
|
3926
3948
|
readMarkdownFile as readMarkdownFile4,
|
|
3927
3949
|
renderDecisions as renderDecisions2,
|
|
3928
3950
|
renderWithMarkers as renderWithMarkers2,
|
|
@@ -3964,7 +3986,7 @@ async function assertWorkspaceInitialized5(basouRoot) {
|
|
|
3964
3986
|
try {
|
|
3965
3987
|
await assertBasouRootSafe5(basouRoot);
|
|
3966
3988
|
} catch (error) {
|
|
3967
|
-
if (
|
|
3989
|
+
if (findErrorCode6(error, "ENOENT")) {
|
|
3968
3990
|
throw new Error("Workspace not initialized. Run 'basou init' first.");
|
|
3969
3991
|
}
|
|
3970
3992
|
throw error;
|
|
@@ -3996,6 +4018,24 @@ import {
|
|
|
3996
4018
|
writeObservedDuration,
|
|
3997
4019
|
writeYamlFile
|
|
3998
4020
|
} from "@basou/core";
|
|
4021
|
+
|
|
4022
|
+
// src/lib/signal-exit-code.ts
|
|
4023
|
+
import { constants } from "os";
|
|
4024
|
+
var PROMISED_SIGNAL_NUMBERS = {
|
|
4025
|
+
SIGHUP: 1,
|
|
4026
|
+
SIGINT: 2,
|
|
4027
|
+
SIGQUIT: 3,
|
|
4028
|
+
SIGKILL: 9,
|
|
4029
|
+
SIGTERM: 15
|
|
4030
|
+
};
|
|
4031
|
+
var UNNUMBERED_SIGNAL_EXIT_CODE = 255;
|
|
4032
|
+
function signalToExitCode(sig) {
|
|
4033
|
+
if (sig === null) return 1;
|
|
4034
|
+
const num = PROMISED_SIGNAL_NUMBERS[sig] ?? constants.signals[sig];
|
|
4035
|
+
return num === void 0 ? UNNUMBERED_SIGNAL_EXIT_CODE : 128 + num;
|
|
4036
|
+
}
|
|
4037
|
+
|
|
4038
|
+
// src/commands/exec.ts
|
|
3999
4039
|
function registerExecCommand(program2) {
|
|
4000
4040
|
program2.command("exec <command> [args...]").description("Execute a command and record it as a Basou session").passThroughOptions().option("--timeout <duration>", "Kill the child after this duration (e.g. 30s, 5m, 1h)").option("--no-snapshot", "Skip git_snapshot before/after the command").option("--cwd <path>", "Run from a Basou root other than process.cwd()").option("-v, --verbose", "Show error causes").action(async (command, args, options) => {
|
|
4001
4041
|
try {
|
|
@@ -4192,18 +4232,6 @@ function decideFinalStatus(result, signalReceived) {
|
|
|
4192
4232
|
if (result.exit_code === 0) return "completed";
|
|
4193
4233
|
return "failed";
|
|
4194
4234
|
}
|
|
4195
|
-
var SIGNUM_MAP = {
|
|
4196
|
-
SIGHUP: 1,
|
|
4197
|
-
SIGINT: 2,
|
|
4198
|
-
SIGQUIT: 3,
|
|
4199
|
-
SIGKILL: 9,
|
|
4200
|
-
SIGTERM: 15
|
|
4201
|
-
};
|
|
4202
|
-
function signalToExitCode(sig) {
|
|
4203
|
-
if (sig === null) return 1;
|
|
4204
|
-
const num = SIGNUM_MAP[sig] ?? 1;
|
|
4205
|
-
return 128 + num;
|
|
4206
|
-
}
|
|
4207
4235
|
async function tryAppendGitSnapshot(sessionDir, sessionId, repoRoot, now, appendEvent) {
|
|
4208
4236
|
let snapshot;
|
|
4209
4237
|
try {
|
|
@@ -4315,7 +4343,7 @@ async function finalizeSessionAsFailed(paths, sessionDir, sessionId, appendEvent
|
|
|
4315
4343
|
import {
|
|
4316
4344
|
assertBasouRootSafe as assertBasouRootSafe7,
|
|
4317
4345
|
basouPaths as basouPaths9,
|
|
4318
|
-
findErrorCode as
|
|
4346
|
+
findErrorCode as findErrorCode7,
|
|
4319
4347
|
readMarkdownFile as readMarkdownFile5,
|
|
4320
4348
|
renderHandoff as renderHandoff2,
|
|
4321
4349
|
renderWithMarkers as renderWithMarkers3,
|
|
@@ -4373,7 +4401,7 @@ async function assertWorkspaceInitialized6(basouRoot) {
|
|
|
4373
4401
|
try {
|
|
4374
4402
|
await assertBasouRootSafe7(basouRoot);
|
|
4375
4403
|
} catch (error) {
|
|
4376
|
-
if (
|
|
4404
|
+
if (findErrorCode7(error, "ENOENT")) {
|
|
4377
4405
|
throw new Error("Workspace not initialized. Run 'basou init' first.");
|
|
4378
4406
|
}
|
|
4379
4407
|
throw error;
|
|
@@ -4624,7 +4652,7 @@ async function loadProtocolsConfig(configPath = DEFAULT_PROTOCOLS_CONFIG_PATH) {
|
|
|
4624
4652
|
import {
|
|
4625
4653
|
assertBasouRootSafe as assertBasouRootSafe8,
|
|
4626
4654
|
basouPaths as basouPaths10,
|
|
4627
|
-
findErrorCode as
|
|
4655
|
+
findErrorCode as findErrorCode8,
|
|
4628
4656
|
renderOrientation as renderOrientation2,
|
|
4629
4657
|
writeMarkdownFile as writeMarkdownFile4
|
|
4630
4658
|
} from "@basou/core";
|
|
@@ -4781,7 +4809,7 @@ async function assertWorkspaceInitialized7(basouRoot) {
|
|
|
4781
4809
|
try {
|
|
4782
4810
|
await assertBasouRootSafe8(basouRoot);
|
|
4783
4811
|
} catch (error) {
|
|
4784
|
-
if (
|
|
4812
|
+
if (findErrorCode8(error, "ENOENT")) {
|
|
4785
4813
|
throw new Error("Workspace not initialized. Run 'basou init' first.");
|
|
4786
4814
|
}
|
|
4787
4815
|
throw error;
|
|
@@ -5836,7 +5864,6 @@ function renderGitignoreWarning(error, verbose) {
|
|
|
5836
5864
|
}
|
|
5837
5865
|
|
|
5838
5866
|
// src/commands/note.ts
|
|
5839
|
-
import { readFile as readFile5 } from "fs/promises";
|
|
5840
5867
|
import { homedir as homedir8 } from "os";
|
|
5841
5868
|
import { resolve as resolve8 } from "path";
|
|
5842
5869
|
import {
|
|
@@ -5846,7 +5873,7 @@ import {
|
|
|
5846
5873
|
basouPaths as basouPaths12,
|
|
5847
5874
|
createAdHocSessionWithEvent as createAdHocSessionWithEvent2,
|
|
5848
5875
|
EVENT_SCHEMA_VERSION as EVENT_SCHEMA_VERSION4,
|
|
5849
|
-
findErrorCode as
|
|
5876
|
+
findErrorCode as findErrorCode9,
|
|
5850
5877
|
LOCAL_CLI_EVENT_SOURCE as LOCAL_CLI_EVENT_SOURCE3,
|
|
5851
5878
|
readManifest as readManifest8,
|
|
5852
5879
|
resolveSessionId as resolveSessionId2,
|
|
@@ -6007,22 +6034,12 @@ async function readNoteBody(bodyArgument, options, ctx, cwd) {
|
|
|
6007
6034
|
if (bodyArgument !== void 0 && options.file !== void 0) {
|
|
6008
6035
|
throw new Error("Pass the note text either as an argument or with --file, not both.");
|
|
6009
6036
|
}
|
|
6037
|
+
refuseDashInputFile("--file", options.file, "stdin");
|
|
6010
6038
|
if (bodyArgument !== void 0) {
|
|
6011
6039
|
return { body: bodyArgument, source: "argument" };
|
|
6012
6040
|
}
|
|
6013
6041
|
if (options.file !== void 0) {
|
|
6014
|
-
|
|
6015
|
-
try {
|
|
6016
|
-
raw = await readFile5(resolve8(cwd, options.file), "utf8");
|
|
6017
|
-
} catch (error) {
|
|
6018
|
-
if (findErrorCode8(error, "ENOENT")) {
|
|
6019
|
-
throw new Error("--file names a file that does not exist", { cause: error });
|
|
6020
|
-
}
|
|
6021
|
-
if (findErrorCode8(error, "EISDIR")) {
|
|
6022
|
-
throw new Error("--file names a directory, not a file", { cause: error });
|
|
6023
|
-
}
|
|
6024
|
-
throw new Error("Could not read the file --file names", { cause: error });
|
|
6025
|
-
}
|
|
6042
|
+
const raw = await readInputFileText("--file", resolve8(cwd, options.file));
|
|
6026
6043
|
return { body: dropTrailingNewlines(raw), source: "file" };
|
|
6027
6044
|
}
|
|
6028
6045
|
if (ctx.readInput !== void 0) {
|
|
@@ -6091,7 +6108,7 @@ async function assertWorkspaceInitialized8(basouRoot) {
|
|
|
6091
6108
|
try {
|
|
6092
6109
|
await assertBasouRootSafe9(basouRoot);
|
|
6093
6110
|
} catch (error) {
|
|
6094
|
-
if (
|
|
6111
|
+
if (findErrorCode9(error, "ENOENT")) {
|
|
6095
6112
|
throw new Error("Workspace not initialized. Run 'basou init' first.");
|
|
6096
6113
|
}
|
|
6097
6114
|
throw error;
|
|
@@ -9420,7 +9437,7 @@ function renderProjectRetrofit(result) {
|
|
|
9420
9437
|
}
|
|
9421
9438
|
|
|
9422
9439
|
// src/commands/protocol.ts
|
|
9423
|
-
import { readFile as
|
|
9440
|
+
import { readFile as readFile5, stat as stat5 } from "fs/promises";
|
|
9424
9441
|
import {
|
|
9425
9442
|
carryForwardProtocolStamp,
|
|
9426
9443
|
PROTOCOL_END as PROTOCOL_END2,
|
|
@@ -9477,7 +9494,7 @@ async function readProtocolSources(entries) {
|
|
|
9477
9494
|
for (const entry of entries) {
|
|
9478
9495
|
let content;
|
|
9479
9496
|
try {
|
|
9480
|
-
content = await
|
|
9497
|
+
content = await readFile5(entry.source, "utf8");
|
|
9481
9498
|
} catch (error) {
|
|
9482
9499
|
if (error instanceof Error && error.code === "ENOENT") {
|
|
9483
9500
|
throw new Error(
|
|
@@ -9603,7 +9620,7 @@ async function doRunProtocolUnsync(options) {
|
|
|
9603
9620
|
import {
|
|
9604
9621
|
assertBasouRootSafe as assertBasouRootSafe10,
|
|
9605
9622
|
basouPaths as basouPaths14,
|
|
9606
|
-
findErrorCode as
|
|
9623
|
+
findErrorCode as findErrorCode11,
|
|
9607
9624
|
loadPortfolioConfig as loadPortfolioConfig5,
|
|
9608
9625
|
readManifest as readManifest10
|
|
9609
9626
|
} from "@basou/core";
|
|
@@ -9617,7 +9634,7 @@ import {
|
|
|
9617
9634
|
assertApprovalStoreSafe as assertApprovalStoreSafe2,
|
|
9618
9635
|
assertLockStoreSafe as assertLockStoreSafe4,
|
|
9619
9636
|
assertTaskStoreSafe as assertTaskStoreSafe2,
|
|
9620
|
-
findErrorCode as
|
|
9637
|
+
findErrorCode as findErrorCode10
|
|
9621
9638
|
} from "@basou/core";
|
|
9622
9639
|
var DEFAULT_WATCH_INTERVAL_SEC = 30;
|
|
9623
9640
|
var MIN_WATCH_INTERVAL_SEC = 5;
|
|
@@ -9635,7 +9652,7 @@ async function scanSourceLogs(roots) {
|
|
|
9635
9652
|
try {
|
|
9636
9653
|
entries = await readdir3(dir, { withFileTypes: true });
|
|
9637
9654
|
} catch (error) {
|
|
9638
|
-
if (
|
|
9655
|
+
if (findErrorCode10(error, "ENOENT") || findErrorCode10(error, "ENOTDIR")) return;
|
|
9639
9656
|
throw new Error("Failed to read a source log directory", { cause: error });
|
|
9640
9657
|
}
|
|
9641
9658
|
for (const entry of entries) {
|
|
@@ -9647,7 +9664,7 @@ async function scanSourceLogs(roots) {
|
|
|
9647
9664
|
const info = await stat6(full);
|
|
9648
9665
|
out.set(full, { mtimeMs: info.mtimeMs, size: info.size });
|
|
9649
9666
|
} catch (error) {
|
|
9650
|
-
if (
|
|
9667
|
+
if (findErrorCode10(error, "ENOENT")) continue;
|
|
9651
9668
|
throw new Error("Failed to stat a source log file", { cause: error });
|
|
9652
9669
|
}
|
|
9653
9670
|
}
|
|
@@ -9981,7 +9998,7 @@ async function assertWorkspaceInitialized9(basouRoot) {
|
|
|
9981
9998
|
try {
|
|
9982
9999
|
await assertBasouRootSafe10(basouRoot);
|
|
9983
10000
|
} catch (error) {
|
|
9984
|
-
if (
|
|
10001
|
+
if (findErrorCode11(error, "ENOENT")) {
|
|
9985
10002
|
throw new Error("Workspace not initialized. Run 'basou init' first.");
|
|
9986
10003
|
}
|
|
9987
10004
|
throw error;
|
|
@@ -9993,7 +10010,7 @@ import { isAbsolute as isAbsolute4, resolve as resolve10 } from "path";
|
|
|
9993
10010
|
import {
|
|
9994
10011
|
assertBasouRootSafe as assertBasouRootSafe11,
|
|
9995
10012
|
basouPaths as basouPaths15,
|
|
9996
|
-
findErrorCode as
|
|
10013
|
+
findErrorCode as findErrorCode12,
|
|
9997
10014
|
renderReport,
|
|
9998
10015
|
writeMarkdownFile as writeMarkdownFile6
|
|
9999
10016
|
} from "@basou/core";
|
|
@@ -10045,7 +10062,7 @@ async function assertWorkspaceInitialized10(basouRoot) {
|
|
|
10045
10062
|
try {
|
|
10046
10063
|
await assertBasouRootSafe11(basouRoot);
|
|
10047
10064
|
} catch (error) {
|
|
10048
|
-
if (
|
|
10065
|
+
if (findErrorCode12(error, "ENOENT")) {
|
|
10049
10066
|
throw new Error("Workspace not initialized. Run 'basou init' first.");
|
|
10050
10067
|
}
|
|
10051
10068
|
throw error;
|
|
@@ -10053,7 +10070,6 @@ async function assertWorkspaceInitialized10(basouRoot) {
|
|
|
10053
10070
|
}
|
|
10054
10071
|
|
|
10055
10072
|
// src/commands/review.ts
|
|
10056
|
-
import { readFile as readFile7 } from "fs/promises";
|
|
10057
10073
|
import { homedir as homedir10 } from "os";
|
|
10058
10074
|
import { resolve as resolve11 } from "path";
|
|
10059
10075
|
import {
|
|
@@ -10062,7 +10078,7 @@ import {
|
|
|
10062
10078
|
buildReviewRecordedEvent,
|
|
10063
10079
|
buildReviewRecordLabel,
|
|
10064
10080
|
createAdHocSessionWithEvent as createAdHocSessionWithEvent3,
|
|
10065
|
-
findErrorCode as
|
|
10081
|
+
findErrorCode as findErrorCode13,
|
|
10066
10082
|
findUnbindableRepos,
|
|
10067
10083
|
parseReviewRecordInput,
|
|
10068
10084
|
readManifest as readManifest11,
|
|
@@ -10138,6 +10154,7 @@ async function runReviewRecord(options, ctx = {}) {
|
|
|
10138
10154
|
}
|
|
10139
10155
|
}
|
|
10140
10156
|
async function doRunReviewRecord(options, ctx) {
|
|
10157
|
+
refuseDashInputFile("--file", options.file, "stdin");
|
|
10141
10158
|
const cwd = ctx.cwd ?? process.cwd();
|
|
10142
10159
|
const repositoryRoot = await resolveBasouRootForCommand(cwd, "review record");
|
|
10143
10160
|
const paths = basouPaths16(repositoryRoot);
|
|
@@ -10196,14 +10213,7 @@ ${detail}
|
|
|
10196
10213
|
}
|
|
10197
10214
|
async function readReviewInput(options, ctx) {
|
|
10198
10215
|
if (options.file !== void 0) {
|
|
10199
|
-
|
|
10200
|
-
return await readFile7(options.file, "utf8");
|
|
10201
|
-
} catch (error) {
|
|
10202
|
-
if (findErrorCode12(error, "ENOENT")) {
|
|
10203
|
-
throw new Error(`Input file not found: ${options.file}`);
|
|
10204
|
-
}
|
|
10205
|
-
throw error;
|
|
10206
|
-
}
|
|
10216
|
+
return await readInputFileText("--file", options.file);
|
|
10207
10217
|
}
|
|
10208
10218
|
if (ctx.readInput !== void 0) {
|
|
10209
10219
|
return await ctx.readInput();
|
|
@@ -10278,7 +10288,7 @@ async function assertWorkspaceInitialized11(basouRoot) {
|
|
|
10278
10288
|
try {
|
|
10279
10289
|
await assertBasouRootSafe12(basouRoot);
|
|
10280
10290
|
} catch (error) {
|
|
10281
|
-
if (
|
|
10291
|
+
if (findErrorCode13(error, "ENOENT")) {
|
|
10282
10292
|
throw new Error("Workspace not initialized. Run 'basou init' first.");
|
|
10283
10293
|
}
|
|
10284
10294
|
throw error;
|
|
@@ -10490,7 +10500,7 @@ function unattachedLines(u) {
|
|
|
10490
10500
|
}
|
|
10491
10501
|
|
|
10492
10502
|
// src/commands/run.ts
|
|
10493
|
-
import { mkdir as mkdir3, readFile as
|
|
10503
|
+
import { mkdir as mkdir3, readFile as readFile6, rm as rm3 } from "fs/promises";
|
|
10494
10504
|
import { homedir as homedir11 } from "os";
|
|
10495
10505
|
import { join as join14 } from "path";
|
|
10496
10506
|
import {
|
|
@@ -10761,7 +10771,7 @@ async function runTrackedTool(args, options, ctx, adapter) {
|
|
|
10761
10771
|
s.session.related_files = relatedFiles;
|
|
10762
10772
|
});
|
|
10763
10773
|
if (result.exit_code !== null) return result.exit_code;
|
|
10764
|
-
return
|
|
10774
|
+
return signalToExitCode(signalReceived ?? result.signal);
|
|
10765
10775
|
}
|
|
10766
10776
|
function decideFinalStatus2(result, signalReceived) {
|
|
10767
10777
|
if (signalReceived === "SIGINT" || signalReceived === "SIGTERM") return "interrupted";
|
|
@@ -10771,18 +10781,6 @@ function decideFinalStatus2(result, signalReceived) {
|
|
|
10771
10781
|
if (result.exit_code === 0) return "completed";
|
|
10772
10782
|
return "failed";
|
|
10773
10783
|
}
|
|
10774
|
-
var SIGNUM_MAP2 = {
|
|
10775
|
-
SIGHUP: 1,
|
|
10776
|
-
SIGINT: 2,
|
|
10777
|
-
SIGQUIT: 3,
|
|
10778
|
-
SIGKILL: 9,
|
|
10779
|
-
SIGTERM: 15
|
|
10780
|
-
};
|
|
10781
|
-
function signalToExitCode2(sig) {
|
|
10782
|
-
if (sig === null) return 1;
|
|
10783
|
-
const num = SIGNUM_MAP2[sig] ?? 1;
|
|
10784
|
-
return 128 + num;
|
|
10785
|
-
}
|
|
10786
10784
|
async function tryAppendGitSnapshot2(sessionDir, sessionId, repoRoot, now, appendEvent) {
|
|
10787
10785
|
let snapshot;
|
|
10788
10786
|
try {
|
|
@@ -10940,7 +10938,7 @@ async function noteCodexHookStatusPreSpawn(_cwd, ctx) {
|
|
|
10940
10938
|
const hooksPath = ctx.codexHooksPath ?? DEFAULT_CODEX_HOOKS_PATH;
|
|
10941
10939
|
let location;
|
|
10942
10940
|
try {
|
|
10943
|
-
location = findBasouSessionStartHook2(JSON.parse(await
|
|
10941
|
+
location = findBasouSessionStartHook2(JSON.parse(await readFile6(hooksPath, "utf8")));
|
|
10944
10942
|
} catch (error) {
|
|
10945
10943
|
if (!(error instanceof Error && error.code === "ENOENT")) return null;
|
|
10946
10944
|
location = null;
|
|
@@ -10954,7 +10952,7 @@ async function noteCodexHookStatusPreSpawn(_cwd, ctx) {
|
|
|
10954
10952
|
}
|
|
10955
10953
|
|
|
10956
10954
|
// src/commands/session.ts
|
|
10957
|
-
import { readFile as
|
|
10955
|
+
import { readFile as readFile7 } from "fs/promises";
|
|
10958
10956
|
import { basename as basename8, isAbsolute as isAbsolute5, join as join15, relative as relative4, sep as sep3 } from "path";
|
|
10959
10957
|
import {
|
|
10960
10958
|
acquireLock as acquireLock6,
|
|
@@ -10965,7 +10963,7 @@ import {
|
|
|
10965
10963
|
displayPath as displayPath5,
|
|
10966
10964
|
EVENT_SCHEMA_VERSION as EVENT_SCHEMA_VERSION6,
|
|
10967
10965
|
enumerateSessionEntries as enumerateSessionEntries2,
|
|
10968
|
-
findErrorCode as
|
|
10966
|
+
findErrorCode as findErrorCode14,
|
|
10969
10967
|
importSessionFromJson as importSessionFromJson2,
|
|
10970
10968
|
LOCAL_CLI_EVENT_SOURCE as LOCAL_CLI_EVENT_SOURCE4,
|
|
10971
10969
|
loadSessionEntries as loadSessionEntries2,
|
|
@@ -11094,7 +11092,7 @@ async function doRunSessionShow(idInput, options, ctx) {
|
|
|
11094
11092
|
const raw = await readYamlFile6(sessionYamlPath);
|
|
11095
11093
|
session = SessionSchema3.parse(normalizeSessionTimestamps(raw));
|
|
11096
11094
|
} catch (error) {
|
|
11097
|
-
if (
|
|
11095
|
+
if (findErrorCode14(error, "ENOENT")) {
|
|
11098
11096
|
throw new Error(`Session not found: ${idInput}`);
|
|
11099
11097
|
}
|
|
11100
11098
|
throw new Error("Failed to read session", { cause: error });
|
|
@@ -11358,7 +11356,7 @@ async function assertWorkspaceInitialized12(basouRoot) {
|
|
|
11358
11356
|
try {
|
|
11359
11357
|
await assertBasouRootSafe14(basouRoot);
|
|
11360
11358
|
} catch (error) {
|
|
11361
|
-
if (
|
|
11359
|
+
if (findErrorCode14(error, "ENOENT")) {
|
|
11362
11360
|
throw new Error("Workspace not initialized. Run 'basou init' first.");
|
|
11363
11361
|
}
|
|
11364
11362
|
throw error;
|
|
@@ -11394,6 +11392,7 @@ async function runSessionImport(options, ctx = {}) {
|
|
|
11394
11392
|
}
|
|
11395
11393
|
}
|
|
11396
11394
|
async function doRunSessionImport(options, ctx) {
|
|
11395
|
+
refuseDashInputFile("--from", options.from, { fileOnly: "the JSON" });
|
|
11397
11396
|
const cwd = ctx.cwd ?? process.cwd();
|
|
11398
11397
|
const repositoryRoot = await resolveRepositoryRootForSession(cwd, "import");
|
|
11399
11398
|
const paths = basouPaths19(repositoryRoot);
|
|
@@ -11427,12 +11426,12 @@ async function doRunSessionImport(options, ctx) {
|
|
|
11427
11426
|
}
|
|
11428
11427
|
async function readInputFile(path) {
|
|
11429
11428
|
try {
|
|
11430
|
-
return await
|
|
11429
|
+
return await readFile7(path, "utf8");
|
|
11431
11430
|
} catch (error) {
|
|
11432
|
-
if (
|
|
11431
|
+
if (findErrorCode14(error, "ENOENT")) {
|
|
11433
11432
|
throw new Error("Import source not found", { cause: error });
|
|
11434
11433
|
}
|
|
11435
|
-
if (
|
|
11434
|
+
if (findErrorCode14(error, "EISDIR")) {
|
|
11436
11435
|
throw new Error("Import source is not a file", { cause: error });
|
|
11437
11436
|
}
|
|
11438
11437
|
throw new Error("Failed to read import source", { cause: error });
|
|
@@ -11507,9 +11506,7 @@ async function doRunSessionNote(sessionIdInput, options, ctx) {
|
|
|
11507
11506
|
if (hasBody && hasFromFile) {
|
|
11508
11507
|
throw new Error("--body and --from-file are mutually exclusive");
|
|
11509
11508
|
}
|
|
11510
|
-
|
|
11511
|
-
throw new Error("--from-file - (stdin) is not supported in v0.1");
|
|
11512
|
-
}
|
|
11509
|
+
refuseDashInputFile("--from-file", options.fromFile, { textFlag: "--body" });
|
|
11513
11510
|
const cwd = ctx.cwd ?? process.cwd();
|
|
11514
11511
|
const repositoryRoot = await resolveRepositoryRootForSession(cwd, "note");
|
|
11515
11512
|
const paths = basouPaths19(repositoryRoot);
|
|
@@ -11544,12 +11541,12 @@ async function doRunSessionNote(sessionIdInput, options, ctx) {
|
|
|
11544
11541
|
}
|
|
11545
11542
|
async function readNoteFile(path) {
|
|
11546
11543
|
try {
|
|
11547
|
-
return await
|
|
11544
|
+
return await readFile7(path, "utf8");
|
|
11548
11545
|
} catch (error) {
|
|
11549
|
-
if (
|
|
11546
|
+
if (findErrorCode14(error, "ENOENT")) {
|
|
11550
11547
|
throw new Error("Note source not found", { cause: error });
|
|
11551
11548
|
}
|
|
11552
|
-
if (
|
|
11549
|
+
if (findErrorCode14(error, "EISDIR")) {
|
|
11553
11550
|
throw new Error("Note source is not a file", { cause: error });
|
|
11554
11551
|
}
|
|
11555
11552
|
throw new Error("Failed to read note source", { cause: error });
|
|
@@ -11662,7 +11659,7 @@ import {
|
|
|
11662
11659
|
assertBasouRootSafe as assertBasouRootSafe15,
|
|
11663
11660
|
basouPaths as basouPaths20,
|
|
11664
11661
|
computeWorkStats,
|
|
11665
|
-
findErrorCode as
|
|
11662
|
+
findErrorCode as findErrorCode15
|
|
11666
11663
|
} from "@basou/core";
|
|
11667
11664
|
function registerStatsCommand(program2) {
|
|
11668
11665
|
program2.command("stats").description("Report how much the AI worked (output volume + time proxies) across sessions").option("--by-source", "Break the totals down by session source kind").option("--by-day", "Break billable time and volume down by calendar day").option("--json", "Output the full stats as JSON").option("-v, --verbose", "Show error causes").action(async (options) => {
|
|
@@ -11771,7 +11768,7 @@ async function assertWorkspaceInitialized13(basouRoot) {
|
|
|
11771
11768
|
try {
|
|
11772
11769
|
await assertBasouRootSafe15(basouRoot);
|
|
11773
11770
|
} catch (error) {
|
|
11774
|
-
if (
|
|
11771
|
+
if (findErrorCode15(error, "ENOENT")) {
|
|
11775
11772
|
throw new Error("Workspace not initialized. Run 'basou init' first.");
|
|
11776
11773
|
}
|
|
11777
11774
|
throw error;
|
|
@@ -11783,7 +11780,7 @@ import {
|
|
|
11783
11780
|
assertBasouRootSafe as assertBasouRootSafe16,
|
|
11784
11781
|
basouPaths as basouPaths21,
|
|
11785
11782
|
buildStatusSnapshot,
|
|
11786
|
-
findErrorCode as
|
|
11783
|
+
findErrorCode as findErrorCode16,
|
|
11787
11784
|
readManifest as readManifest14,
|
|
11788
11785
|
writeStatus
|
|
11789
11786
|
} from "@basou/core";
|
|
@@ -11807,7 +11804,7 @@ async function doRunStatus(options, ctx) {
|
|
|
11807
11804
|
try {
|
|
11808
11805
|
await assertBasouRootSafe16(paths.root);
|
|
11809
11806
|
} catch (error) {
|
|
11810
|
-
if (
|
|
11807
|
+
if (findErrorCode16(error, "ENOENT")) {
|
|
11811
11808
|
throw new Error("Workspace not initialized. Run 'basou init' first.");
|
|
11812
11809
|
}
|
|
11813
11810
|
throw error;
|
|
@@ -11816,7 +11813,7 @@ async function doRunStatus(options, ctx) {
|
|
|
11816
11813
|
try {
|
|
11817
11814
|
manifest = await readManifest14(paths);
|
|
11818
11815
|
} catch (error) {
|
|
11819
|
-
if (
|
|
11816
|
+
if (findErrorCode16(error, "ENOENT")) {
|
|
11820
11817
|
throw new Error("Workspace not initialized. Run 'basou init' first.");
|
|
11821
11818
|
}
|
|
11822
11819
|
const gateMessage = formatVersionGateMessage(error);
|
|
@@ -11854,7 +11851,7 @@ function formatVersionGateMessage(error) {
|
|
|
11854
11851
|
}
|
|
11855
11852
|
|
|
11856
11853
|
// src/commands/task.ts
|
|
11857
|
-
import { readFile as
|
|
11854
|
+
import { readFile as readFile8 } from "fs/promises";
|
|
11858
11855
|
import { join as join16 } from "path";
|
|
11859
11856
|
import {
|
|
11860
11857
|
archiveTask,
|
|
@@ -11865,7 +11862,7 @@ import {
|
|
|
11865
11862
|
deleteTask,
|
|
11866
11863
|
editTask,
|
|
11867
11864
|
enumerateArchivedTaskIds,
|
|
11868
|
-
findErrorCode as
|
|
11865
|
+
findErrorCode as findErrorCode17,
|
|
11869
11866
|
loadSessionEntries as loadSessionEntries3,
|
|
11870
11867
|
loadTaskEntries,
|
|
11871
11868
|
prefixedUlid as prefixedUlid5,
|
|
@@ -11952,9 +11949,7 @@ async function doRunTaskNew(options, ctx) {
|
|
|
11952
11949
|
if (options.description !== void 0 && options.fromFile !== void 0) {
|
|
11953
11950
|
throw new Error("--description and --from-file are mutually exclusive");
|
|
11954
11951
|
}
|
|
11955
|
-
|
|
11956
|
-
throw new Error("--from-file - (stdin) is not supported in v0.1");
|
|
11957
|
-
}
|
|
11952
|
+
refuseDashInputFile("--from-file", options.fromFile, { textFlag: "--description" });
|
|
11958
11953
|
const initialStatus = options.status ?? "planned";
|
|
11959
11954
|
if (options.completedAt !== void 0 && !isTerminalStatusForCli(initialStatus)) {
|
|
11960
11955
|
throw new Error("--completed-at requires --status done or cancelled");
|
|
@@ -12871,12 +12866,12 @@ function parsePositiveInt2(raw) {
|
|
|
12871
12866
|
}
|
|
12872
12867
|
async function readDescriptionFile(path) {
|
|
12873
12868
|
try {
|
|
12874
|
-
return await
|
|
12869
|
+
return await readFile8(path, "utf8");
|
|
12875
12870
|
} catch (error) {
|
|
12876
|
-
if (
|
|
12871
|
+
if (findErrorCode17(error, "ENOENT")) {
|
|
12877
12872
|
throw new Error("Description source not found", { cause: error });
|
|
12878
12873
|
}
|
|
12879
|
-
if (
|
|
12874
|
+
if (findErrorCode17(error, "EISDIR")) {
|
|
12880
12875
|
throw new Error("Description source is not a file", { cause: error });
|
|
12881
12876
|
}
|
|
12882
12877
|
throw new Error("Failed to read description source", { cause: error });
|
|
@@ -12889,7 +12884,7 @@ async function assertWorkspaceInitialized14(basouRoot) {
|
|
|
12889
12884
|
try {
|
|
12890
12885
|
await assertBasouRootSafe17(basouRoot);
|
|
12891
12886
|
} catch (error) {
|
|
12892
|
-
if (
|
|
12887
|
+
if (findErrorCode17(error, "ENOENT")) {
|
|
12893
12888
|
throw new Error("Workspace not initialized. Run 'basou init' first.");
|
|
12894
12889
|
}
|
|
12895
12890
|
throw error;
|
|
@@ -12980,7 +12975,7 @@ import {
|
|
|
12980
12975
|
assertBasouRootSafe as assertBasouRootSafe18,
|
|
12981
12976
|
basouPaths as basouPaths23,
|
|
12982
12977
|
enumerateSessionEntries as enumerateSessionEntries3,
|
|
12983
|
-
findErrorCode as
|
|
12978
|
+
findErrorCode as findErrorCode18,
|
|
12984
12979
|
resolveSessionId as resolveSessionId5,
|
|
12985
12980
|
verifyEventsChain
|
|
12986
12981
|
} from "@basou/core";
|
|
@@ -13067,7 +13062,7 @@ async function assertWorkspaceInitialized15(basouRoot) {
|
|
|
13067
13062
|
try {
|
|
13068
13063
|
await assertBasouRootSafe18(basouRoot);
|
|
13069
13064
|
} catch (error) {
|
|
13070
|
-
if (
|
|
13065
|
+
if (findErrorCode18(error, "ENOENT")) {
|
|
13071
13066
|
throw new Error("Workspace not initialized. Run 'basou init' first.");
|
|
13072
13067
|
}
|
|
13073
13068
|
throw error;
|
|
@@ -13081,7 +13076,7 @@ import { basename as basename11, dirname as dirname9, join as join20, resolve as
|
|
|
13081
13076
|
import {
|
|
13082
13077
|
assertBasouRootSafe as assertBasouRootSafe19,
|
|
13083
13078
|
basouPaths as basouPaths25,
|
|
13084
|
-
findErrorCode as
|
|
13079
|
+
findErrorCode as findErrorCode20,
|
|
13085
13080
|
loadPortfolioConfig as loadPortfolioConfig6,
|
|
13086
13081
|
readManifest as readManifest19
|
|
13087
13082
|
} from "@basou/core";
|
|
@@ -13597,7 +13592,7 @@ import {
|
|
|
13597
13592
|
boardPageUnavailable,
|
|
13598
13593
|
computeWorkStats as computeWorkStats2,
|
|
13599
13594
|
enumerateApprovals as enumerateApprovals2,
|
|
13600
|
-
findErrorCode as
|
|
13595
|
+
findErrorCode as findErrorCode19,
|
|
13601
13596
|
inspectSessionEntry as inspectSessionEntry2,
|
|
13602
13597
|
isLazyExpired as isLazyExpired2,
|
|
13603
13598
|
loadApproval as loadApproval2,
|
|
@@ -15546,7 +15541,7 @@ async function overview(ws, nowProvider, resolveRemoteUrl) {
|
|
|
15546
15541
|
try {
|
|
15547
15542
|
manifest = await readManifest18(ws.paths);
|
|
15548
15543
|
} catch (error) {
|
|
15549
|
-
if (
|
|
15544
|
+
if (findErrorCode19(error, "ENOENT")) {
|
|
15550
15545
|
return { initialized: false, repoRoot: ws.repoRoot };
|
|
15551
15546
|
}
|
|
15552
15547
|
throw error;
|
|
@@ -15956,7 +15951,7 @@ async function startListening(port, deps) {
|
|
|
15956
15951
|
try {
|
|
15957
15952
|
return await startViewServer({ port, deps });
|
|
15958
15953
|
} catch (error) {
|
|
15959
|
-
if (
|
|
15954
|
+
if (findErrorCode20(error, "EADDRINUSE")) {
|
|
15960
15955
|
throw new Error(`Port ${port} is already in use. Pass --port <n> to choose another.`, {
|
|
15961
15956
|
cause: error
|
|
15962
15957
|
});
|
|
@@ -16009,7 +16004,7 @@ async function assertWorkspaceInitialized16(basouRoot) {
|
|
|
16009
16004
|
try {
|
|
16010
16005
|
await assertBasouRootSafe19(basouRoot);
|
|
16011
16006
|
} catch (error) {
|
|
16012
|
-
if (
|
|
16007
|
+
if (findErrorCode20(error, "ENOENT")) {
|
|
16013
16008
|
throw new Error("Workspace not initialized. Run 'basou init' first.");
|
|
16014
16009
|
}
|
|
16015
16010
|
throw error;
|
|
@@ -16048,7 +16043,7 @@ function installExperimentalNotice(program2, names = EXPERIMENTAL_COMMANDS, writ
|
|
|
16048
16043
|
function readBuildStamp() {
|
|
16049
16044
|
if (false) return void 0;
|
|
16050
16045
|
try {
|
|
16051
|
-
return JSON.parse('{"version":"0.
|
|
16046
|
+
return JSON.parse('{"version":"0.69.0","commit":"bffcfee","committedAt":"2026-10-16T08:07:08+09:00"}');
|
|
16052
16047
|
} catch {
|
|
16053
16048
|
return void 0;
|
|
16054
16049
|
}
|