Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "https://biomejs.dev/schemas/2.4.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"includes": ["**", "!!**/dist"]
},
"formatter": {
"enabled": true,
"indentStyle": "tab"
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
25 changes: 25 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 54 additions & 50 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,56 @@
{
"name": "@dev_desh/flux-cap",
"type": "module",
"version": "0.7.1",
"description": "Git-aware CLI context manager for ADHD developers",
"bin": {
"flux": "./dist/index.js"
},
"files": [
"dist/**/*",
"README.md",
"LICENSE"
],
"scripts": {
"build": "bun build src/index.ts --outdir dist --target node --format esm",
"dev": "bun run src/index.ts",
"prepublishOnly": "bun run build",
"publish": "npm publish --access=public",
"local-install": "bun run build && npm link",
"local-uninstall": "npm unlink -g flux-cap",
"local-reinstall": "bun run local-uninstall && bun run local-install",
"changeset": "changeset",
"changeset:add": "changeset add",
"changeset:status": "changeset status",
"changeset:version": "changeset version",
"changeset:publish": "changeset publish"
},
"engines": {
"node": ">=18.0.0"
},
"keywords": [
"cli",
"productivity",
"adhd",
"git",
"context-switching",
"brain-dump",
"developer-tools"
],
"dependencies": {
"inquirer": "^13.2.5"
},
"devDependencies": {
"@changesets/cli": "^2.29.8",
"@types/inquirer": "^9.0.9"
},
"repository": {
"type": "git",
"url": "https://github.com/kaustubh285/flux-cap"
},
"license": "MIT"
"name": "@dev_desh/flux-cap",
"type": "module",
"version": "0.7.0",
"description": "Git-aware CLI context manager for ADHD developers",
"bin": {
"flux": "./dist/index.js"
},
"files": [
"dist/**/*",
"README.md",
"LICENSE"
],
"scripts": {
"build": "bun build src/index.ts --outdir dist --target node --format esm",
"dev": "bun run src/index.ts",
"prepublishOnly": "bun run build",
"publish": "npm publish --access=public",
"local-install": "bun run build && npm link",
"local-uninstall": "npm unlink -g flux-cap",
"local-reinstall": "bun run local-uninstall && bun run local-install",
"changeset": "changeset",
"changeset:add": "changeset add",
"changeset:status": "changeset status",
"changeset:version": "changeset version",
"changeset:publish": "changeset publish",
"format": "bunx --bun @biomejs/biome check --write"
},
"engines": {
"node": ">=18.0.0"
},
"keywords": [
"cli",
"productivity",
"adhd",
"git",
"context-switching",
"brain-dump",
"developer-tools"
],
"dependencies": {
"commander": "^14.0.3",
"fuse.js": "^7.1.0",
"inquirer": "^13.2.5"
},
"devDependencies": {
"@biomejs/biome": "2.4.4",
"@changesets/cli": "^2.29.8",
"@types/inquirer": "^9.0.9"
},
"repository": {
"type": "git",
"url": "https://github.com/kaustubh285/flux-cap"
},
"license": "MIT"
}
25 changes: 17 additions & 8 deletions src/commands/config.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,32 @@ import { getConfigFile, getFluxPath } from "../utils/lib";

export async function configCommand(data: string[]) {
console.log(`Updating key: ${data[0]} to ${data[1]}`);
const fluxPath = await getFluxPath()
const fluxPath = await getFluxPath();
const fs = await import("fs");
const config = await getConfigFile(fluxPath);

if (data.length < 2) {
console.log("Please provide a key and value to update the config. Example: flux config --add-tags notes ideas tasks");
console.log(
"Please provide a key and value to update the config. Example: flux config --add-tags notes ideas tasks",
);
return;
}
const key = data[0];
const value = data.slice(1).join(' ');
const value = data.slice(1).join(" ");
const editableKeys = [
"hideWorkingDir",
"hideBranchName",
"hideUncommittedChanges",
"resultLimit",
"threshold",
"includeScore",
"defaultFocusDuration"
]
"defaultFocusDuration",
];

if (!editableKeys.includes(key)) {
console.log(`Invalid config key.\nEditable keys are: ${editableKeys.join(', ')}`);
console.log(
`Invalid config key.\nEditable keys are: ${editableKeys.join(", ")}`,
);
return;
}

Expand Down Expand Up @@ -72,12 +76,17 @@ export async function configCommand(data: string[]) {
if (!isNaN(duration)) {
config.defaultFocusDuration = duration;
} else {
console.log("Invalid value for defaultFocusDuration. Please provide a number.");
console.log(
"Invalid value for defaultFocusDuration. Please provide a number.",
);
return;
}
}

fs.writeFileSync(fluxPath + FLUX_CONFIG_PATH, JSON.stringify(config, null, 4));
fs.writeFileSync(
fluxPath + FLUX_CONFIG_PATH,
JSON.stringify(config, null, 4),
);

console.log("Config updated successfully.");
}
75 changes: 47 additions & 28 deletions src/commands/dump.command.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
import { editor } from "@inquirer/prompts";
import { randomUUID } from "crypto";
import type { BrainDump, BrainDumpOptions, FluxConfig } from "../types";
import {
createBrainDumpFileIfNotExists,
getConfigFile,
getCurrentBranch,
getFluxPath,
getGitUncommittedChanges,
getMonthString,
getTags,
getWorkingDir,
} from "../utils/";
import { FLUX_BRAIN_DUMP_PATH, FLUX_CONFIG_PATH } from "../utils/constants";
import { createBrainDumpFileIfNotExists, getConfigFile, getCurrentBranch, getFluxPath, getGitUncommittedChanges, getMonthString, getTags, getWorkingDir } from "../utils/";
import { editor } from '@inquirer/prompts';


export async function handleBrainDump(message: string[], options: BrainDumpOptions) {
export async function handleBrainDump(
message: string[],
options: BrainDumpOptions,
) {
try {
let finalMessage: string;

if (options.multiline) {
console.log('Opening editor for multiline input...');
const initialText = message ? message.join(' ') : '';
console.log("Opening editor for multiline input...");
const initialText = message ? message.join(" ") : "";

const multilineInput = await editor({
message: 'Enter your brain dump (save & exit when done):',
message: "Enter your brain dump (save & exit when done):",
default: initialText,
waitForUserInput: false
waitForUserInput: false,
});

if (!multilineInput.trim()) {
console.log('Brain dump cancelled - no content provided');
console.log("Brain dump cancelled - no content provided");
return;
}

Expand All @@ -30,58 +41,66 @@ export async function handleBrainDump(message: string[], options: BrainDumpOptio
console.log('Please provide a message: flux dump "your message"');
return;
}
finalMessage = message.join(' ');
finalMessage = message.join(" ");
}

await brainDumpAddCommand(finalMessage, options);

} catch (error) {
console.error('Error creating brain dump:', error instanceof Error ? error.message : 'Unknown error');
console.error(
"Error creating brain dump:",
error instanceof Error ? error.message : "Unknown error",
);
process.exit(1);
}
}


export async function brainDumpAddCommand(message: string, options: BrainDumpOptions = {}) {
const fluxPath = await getFluxPath()
export async function brainDumpAddCommand(
message: string,
options: BrainDumpOptions = {},
) {
const fluxPath = await getFluxPath();
const fs = await import("fs");



console.log("Creating brain dump...");

const monthString = getMonthString();
await createBrainDumpFileIfNotExists(monthString, fluxPath);

const config = await getConfigFile(fluxPath);
const workingDir = await getWorkingDir(config)
const branch = getCurrentBranch(config)
const workingDir = await getWorkingDir(config);
const branch = getCurrentBranch(config);
const hasUncommittedChanges = getGitUncommittedChanges(config);
const tags = getTags(options, config);


const newDump: BrainDump = {
id: randomUUID(),
timestamp: new Date().toISOString(),
message: message,
workingDir,
branch,
hasUncommittedChanges,
tags
tags,
};

const data: { dumps: BrainDump[] } = JSON.parse(fs.readFileSync(`${fluxPath}${FLUX_BRAIN_DUMP_PATH}/${monthString}.json`, 'utf8'));
const data: { dumps: BrainDump[] } = JSON.parse(
fs.readFileSync(
`${fluxPath}${FLUX_BRAIN_DUMP_PATH}/${monthString}.json`,
"utf8",
),
);

config.sorted ? data.dumps.unshift(newDump) : data.dumps.push(newDump);

fs.writeFileSync(`${fluxPath}${FLUX_BRAIN_DUMP_PATH}/${monthString}.json`, JSON.stringify(data, null, 2));
fs.writeFileSync(
`${fluxPath}${FLUX_BRAIN_DUMP_PATH}/${monthString}.json`,
JSON.stringify(data, null, 2),
);

const displayMessage = message.length > 50
? message.substring(0, 47) + "..."
: message;
const displayMessage =
message.length > 50 ? message.substring(0, 47) + "..." : message;

const preview = message.includes('\n')
? `${message.split('\n')[0]}... (multiline)`
const preview = message.includes("\n")
? `${message.split("\n")[0]}... (multiline)`
: displayMessage;

console.log(`✅ Brain dump saved: "${preview}"`);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/flux.option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getConfigFile } from "../utils";

export async function versionOption() {
const config = await getConfigFile();
console.log(`flux-cap version: ${config?.fluxVersion || 'unknown'}`);
console.log(`flux-cap version: ${config?.fluxVersion || "unknown"}`);
}

export function helpOption() {
Expand Down
Loading