@basestream/cli 0.2.0 → 0.2.2
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.
Potentially problematic release.
This version of @basestream/cli might be problematic. Click here for more details.
- package/dist/cli.mjs +103 -12
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -921,6 +921,12 @@ async function login() {
|
|
|
921
921
|
var CLAUDE_DIR = path2.join(os2.homedir(), ".claude");
|
|
922
922
|
var CLAUDE_SETTINGS_PATH = path2.join(CLAUDE_DIR, "settings.json");
|
|
923
923
|
var CLAUDE_SKILLS_PATH = path2.join(CLAUDE_DIR, "skills", "bs-summarize.md");
|
|
924
|
+
var CLAUDE_MD_PATH = path2.join(CLAUDE_DIR, "CLAUDE.md");
|
|
925
|
+
var CLAUDE_MD_MARKER = "<!-- basestream -->";
|
|
926
|
+
var CLAUDE_MD_RULE = `${CLAUDE_MD_MARKER}
|
|
927
|
+
- Before starting any non-trivial task, if the reason or context behind the work isn't already clear, ask: "What's the context for this?" Skip this for small tasks, typo fixes, or anything self-explanatory.
|
|
928
|
+
- After completing any meaningful work (fixing a bug, implementing a feature, making a significant change), invoke /bs-summarize to keep the session summary up to date. Include the "why" if it was provided.
|
|
929
|
+
<!-- /basestream -->`;
|
|
924
930
|
var HOOK_COMMAND = "npx @basestream/cli _hook-stop";
|
|
925
931
|
var HOOK_MARKER = "_hook-stop";
|
|
926
932
|
var SKILL_CONTENT = `---
|
|
@@ -928,15 +934,39 @@ name: bs-summarize
|
|
|
928
934
|
description: Update the Basestream session summary with what's been accomplished so far
|
|
929
935
|
---
|
|
930
936
|
|
|
931
|
-
|
|
937
|
+
First, read the existing summary file at \`~/.basestream/sessions/\${CLAUDE_SESSION_ID}-summary.md\` if it exists \u2014 this is the running record of work done so far this session.
|
|
938
|
+
|
|
939
|
+
Then write an updated summary that aggregates the previous summary with everything that has happened since. Focus on:
|
|
940
|
+
- Why the work was done (if context was provided \u2014 skip if not known)
|
|
932
941
|
- What was built, fixed, or changed (be specific about features/bugs)
|
|
933
942
|
- Which parts of the codebase were touched
|
|
934
943
|
- Any key decisions made
|
|
935
944
|
|
|
936
|
-
|
|
945
|
+
Do not just append \u2014 synthesize everything into a single cohesive summary. Merge related work together, avoid repeating the same point twice, and drop anything superseded by later changes. Be concise \u2014 let the scope of the work determine the length. A small fix deserves one sentence; a large multi-part session can be a short paragraph. Plain prose, no bullet points.
|
|
937
946
|
|
|
938
|
-
Write the
|
|
947
|
+
Write the result to \`~/.basestream/sessions/\${CLAUDE_SESSION_ID}-summary.md\`, overwriting the file.
|
|
939
948
|
`;
|
|
949
|
+
function injectClaudeMdRule() {
|
|
950
|
+
let existing = "";
|
|
951
|
+
if (fs2.existsSync(CLAUDE_MD_PATH)) {
|
|
952
|
+
existing = fs2.readFileSync(CLAUDE_MD_PATH, "utf-8");
|
|
953
|
+
}
|
|
954
|
+
let updated;
|
|
955
|
+
if (existing.includes(CLAUDE_MD_MARKER)) {
|
|
956
|
+
updated = existing.replace(/<!-- basestream -->[\s\S]*?<!-- \/basestream -->/, CLAUDE_MD_RULE);
|
|
957
|
+
fs2.writeFileSync(CLAUDE_MD_PATH, updated);
|
|
958
|
+
check("Updated Basestream rules in ~/.claude/CLAUDE.md");
|
|
959
|
+
} else {
|
|
960
|
+
updated = existing ? `${existing.trimEnd()}
|
|
961
|
+
|
|
962
|
+
${CLAUDE_MD_RULE}
|
|
963
|
+
` : `${CLAUDE_MD_RULE}
|
|
964
|
+
`;
|
|
965
|
+
fs2.mkdirSync(CLAUDE_DIR, { recursive: true });
|
|
966
|
+
fs2.writeFileSync(CLAUDE_MD_PATH, updated);
|
|
967
|
+
check("Injected Basestream rules into ~/.claude/CLAUDE.md");
|
|
968
|
+
}
|
|
969
|
+
}
|
|
940
970
|
function installSkill() {
|
|
941
971
|
const skillsDir = path2.dirname(CLAUDE_SKILLS_PATH);
|
|
942
972
|
fs2.mkdirSync(skillsDir, { recursive: true });
|
|
@@ -1009,15 +1039,11 @@ async function init() {
|
|
|
1009
1039
|
console.log();
|
|
1010
1040
|
injectClaudeCodeHook();
|
|
1011
1041
|
installSkill();
|
|
1042
|
+
injectClaudeMdRule();
|
|
1012
1043
|
ensureDirs();
|
|
1013
1044
|
check(`Created ~/.basestream/buffer/`);
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
check("Already authenticated");
|
|
1017
|
-
} else {
|
|
1018
|
-
console.log();
|
|
1019
|
-
await login();
|
|
1020
|
-
}
|
|
1045
|
+
console.log();
|
|
1046
|
+
await login();
|
|
1021
1047
|
console.log();
|
|
1022
1048
|
console.log(
|
|
1023
1049
|
` ${c.dim("That's it. Work normally \u2014 every session is now tracked.")}`
|
|
@@ -4310,7 +4336,7 @@ function flushToBuffer(acc) {
|
|
|
4310
4336
|
whatChanged: Array.from(acc.filesWritten).map(
|
|
4311
4337
|
(f) => path5.relative(acc.cwd, f) || f
|
|
4312
4338
|
),
|
|
4313
|
-
outcome: WorkOutcome.
|
|
4339
|
+
outcome: WorkOutcome.COMPLETED,
|
|
4314
4340
|
filesTouched: acc.filesWritten.size,
|
|
4315
4341
|
complexity,
|
|
4316
4342
|
toolVersion: null,
|
|
@@ -4401,6 +4427,66 @@ async function hookStop() {
|
|
|
4401
4427
|
}
|
|
4402
4428
|
}
|
|
4403
4429
|
|
|
4430
|
+
// src/cli/commands/uninstall.ts
|
|
4431
|
+
init_util();
|
|
4432
|
+
import fs6 from "node:fs";
|
|
4433
|
+
import path6 from "node:path";
|
|
4434
|
+
import os4 from "node:os";
|
|
4435
|
+
var CLAUDE_SETTINGS_PATH2 = path6.join(
|
|
4436
|
+
os4.homedir(),
|
|
4437
|
+
".claude",
|
|
4438
|
+
"settings.json"
|
|
4439
|
+
);
|
|
4440
|
+
var HOOK_MARKER2 = "_hook-stop";
|
|
4441
|
+
function removeClaudeCodeHook() {
|
|
4442
|
+
if (!fs6.existsSync(CLAUDE_SETTINGS_PATH2)) {
|
|
4443
|
+
warn("No Claude Code settings found \u2014 nothing to remove");
|
|
4444
|
+
return false;
|
|
4445
|
+
}
|
|
4446
|
+
let settings;
|
|
4447
|
+
try {
|
|
4448
|
+
settings = JSON.parse(fs6.readFileSync(CLAUDE_SETTINGS_PATH2, "utf-8"));
|
|
4449
|
+
} catch {
|
|
4450
|
+
warn("Could not parse ~/.claude/settings.json");
|
|
4451
|
+
return false;
|
|
4452
|
+
}
|
|
4453
|
+
const hooks = settings.hooks;
|
|
4454
|
+
if (!hooks || !Array.isArray(hooks.Stop)) {
|
|
4455
|
+
warn("No Basestream hook installed");
|
|
4456
|
+
return false;
|
|
4457
|
+
}
|
|
4458
|
+
const before = hooks.Stop.length;
|
|
4459
|
+
hooks.Stop = hooks.Stop.filter(
|
|
4460
|
+
(entry) => !entry.hooks?.some((h) => h.command?.includes(HOOK_MARKER2))
|
|
4461
|
+
);
|
|
4462
|
+
const after = hooks.Stop.length;
|
|
4463
|
+
if (before === after) {
|
|
4464
|
+
warn("No Basestream hook installed");
|
|
4465
|
+
return false;
|
|
4466
|
+
}
|
|
4467
|
+
if (hooks.Stop.length === 0) {
|
|
4468
|
+
delete hooks.Stop;
|
|
4469
|
+
}
|
|
4470
|
+
if (Object.keys(hooks).length === 0) {
|
|
4471
|
+
delete settings.hooks;
|
|
4472
|
+
}
|
|
4473
|
+
fs6.writeFileSync(CLAUDE_SETTINGS_PATH2, JSON.stringify(settings, null, 2));
|
|
4474
|
+
check("Removed tracking hook from ~/.claude/settings.json");
|
|
4475
|
+
return true;
|
|
4476
|
+
}
|
|
4477
|
+
async function uninstall() {
|
|
4478
|
+
console.log();
|
|
4479
|
+
removeClaudeCodeHook();
|
|
4480
|
+
console.log();
|
|
4481
|
+
console.log(
|
|
4482
|
+
` ${c.dim("Basestream will no longer track new Claude Code sessions.")}`
|
|
4483
|
+
);
|
|
4484
|
+
console.log(
|
|
4485
|
+
` ${c.dim("Your ~/.basestream/ buffer and credentials are preserved.")}`
|
|
4486
|
+
);
|
|
4487
|
+
console.log();
|
|
4488
|
+
}
|
|
4489
|
+
|
|
4404
4490
|
// src/cli/index.ts
|
|
4405
4491
|
var HELP = `
|
|
4406
4492
|
basestream \u2014 AI work intelligence for teams
|
|
@@ -4413,6 +4499,7 @@ Commands:
|
|
|
4413
4499
|
basestream login Authenticate with your Basestream account
|
|
4414
4500
|
basestream status Show this week's logged sessions
|
|
4415
4501
|
basestream sync Manually sync buffered entries to Basestream
|
|
4502
|
+
basestream uninstall Remove the Claude Code tracking hook
|
|
4416
4503
|
|
|
4417
4504
|
Options:
|
|
4418
4505
|
--help, -h Show this help message
|
|
@@ -4425,7 +4512,7 @@ async function main() {
|
|
|
4425
4512
|
process.exit(0);
|
|
4426
4513
|
}
|
|
4427
4514
|
if (command === "--version" || command === "-v") {
|
|
4428
|
-
console.log(true ? "0.2.
|
|
4515
|
+
console.log(true ? "0.2.2" : "dev");
|
|
4429
4516
|
process.exit(0);
|
|
4430
4517
|
}
|
|
4431
4518
|
switch (command || "init") {
|
|
@@ -4443,6 +4530,10 @@ async function main() {
|
|
|
4443
4530
|
case "sync":
|
|
4444
4531
|
await sync();
|
|
4445
4532
|
break;
|
|
4533
|
+
case "uninstall":
|
|
4534
|
+
await uninstall();
|
|
4535
|
+
process.exit(0);
|
|
4536
|
+
break;
|
|
4446
4537
|
case "_hook-stop":
|
|
4447
4538
|
await hookStop();
|
|
4448
4539
|
break;
|
package/package.json
CHANGED