claude-think 0.4.2 → 0.5.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.
Files changed (55) hide show
  1. package/README.md +0 -1
  2. package/package.json +3 -2
  3. package/src/cli/commands/context.ts +69 -0
  4. package/src/cli/commands/learn.ts +24 -23
  5. package/src/cli/commands/setup.ts +828 -611
  6. package/src/cli/commands/status.ts +57 -57
  7. package/src/cli/commands/switch.ts +32 -0
  8. package/src/cli/index.ts +61 -134
  9. package/src/core/banner.ts +4 -21
  10. package/src/core/budget.ts +96 -0
  11. package/src/core/config.ts +34 -13
  12. package/src/core/context.ts +498 -0
  13. package/src/core/extractor.ts +373 -0
  14. package/src/core/file-tree.ts +104 -25
  15. package/src/core/generator.ts +144 -22
  16. package/src/core/names.ts +1 -1
  17. package/src/core/project-config.ts +143 -0
  18. package/src/core/project-detect.ts +12 -10
  19. package/src/core/schemas.ts +53 -0
  20. package/src/core/security.ts +24 -0
  21. package/src/tui/App.tsx +140 -143
  22. package/src/tui/components/Agents.tsx +153 -111
  23. package/src/tui/components/Automation.tsx +81 -47
  24. package/src/tui/components/FullScreen.tsx +0 -10
  25. package/src/tui/components/Help.tsx +54 -53
  26. package/src/tui/components/Memory.tsx +120 -145
  27. package/src/tui/components/Navigation.tsx +82 -47
  28. package/src/tui/components/Preferences.tsx +70 -52
  29. package/src/tui/components/Preview.tsx +30 -16
  30. package/src/tui/components/Profile.tsx +122 -43
  31. package/src/tui/components/ProfileSwitcher.tsx +44 -52
  32. package/src/tui/components/Search.tsx +18 -18
  33. package/src/tui/components/Skills.tsx +152 -110
  34. package/src/tui/components/StatusBar.tsx +49 -85
  35. package/src/tui/index.tsx +19 -3
  36. package/.claude/settings.local.json +0 -39
  37. package/.think.yaml +0 -30
  38. package/bun.lock +0 -156
  39. package/src/cli/commands/allow.ts +0 -46
  40. package/src/cli/commands/edit.ts +0 -64
  41. package/src/cli/commands/help.ts +0 -63
  42. package/src/cli/commands/init.ts +0 -83
  43. package/src/cli/commands/profile-commands.ts +0 -142
  44. package/src/cli/commands/profile.ts +0 -30
  45. package/src/cli/commands/project-learn.ts +0 -113
  46. package/src/cli/commands/review.ts +0 -130
  47. package/src/cli/commands/sync.ts +0 -43
  48. package/src/cli/commands/tree.ts +0 -30
  49. package/src/templates/allowed-commands.md +0 -19
  50. package/src/templates/corrections.md +0 -4
  51. package/src/templates/pending.md +0 -5
  52. package/src/templates/settings.md +0 -6
  53. package/src/tui/components/Permissions.tsx +0 -92
  54. package/src/tui/components/QuickActions.tsx +0 -155
  55. package/tsconfig.json +0 -29
package/README.md CHANGED
@@ -111,7 +111,6 @@ Run `think` to launch the fullscreen TUI:
111
111
  - **Tools** - Package manager, languages, editor
112
112
  - **Patterns** - Coding patterns to follow
113
113
  - **Anti-patterns** - Things to avoid
114
- - **Permissions** - Pre-approved commands (no prompts)
115
114
  - **Memory** - Learnings that persist across sessions
116
115
  - **Skills & Agents** - Custom workflows for Claude
117
116
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-think",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "Personal context manager for Claude - manage your preferences, patterns, and memory",
5
5
  "author": "Amit Feldman",
6
6
  "license": "MIT",
@@ -34,6 +34,7 @@
34
34
  "ink": "^6.6.0",
35
35
  "ink-text-input": "^6.0.0",
36
36
  "react": "^19.2.4",
37
- "string-similarity": "^4.0.4"
37
+ "string-similarity": "^4.0.4",
38
+ "zod": "^4.3.6"
38
39
  }
39
40
  }
@@ -0,0 +1,69 @@
1
+ import chalk from "chalk";
2
+ import { getProjectClaudeMdPath } from "../../core/config.ts";
3
+ import { generateProjectContext } from "../../core/context.ts";
4
+ import type { ContextResult } from "../../core/context.ts";
5
+
6
+ export async function contextCommand(options: {
7
+ budget?: string;
8
+ force?: boolean;
9
+ dryRun?: boolean;
10
+ }): Promise<void> {
11
+ const projectDir = process.cwd();
12
+
13
+ console.log(` ${chalk.dim("Scanning project...")}`);
14
+
15
+ let result: ContextResult;
16
+ try {
17
+ result = await generateProjectContext(projectDir, {
18
+ budget: options.budget ? parseInt(options.budget, 10) : undefined,
19
+ force: options.force,
20
+ dryRun: options.dryRun,
21
+ });
22
+ } catch (err) {
23
+ const message = err instanceof Error ? err.message : String(err);
24
+ console.log(` ${chalk.red("\u25C6")} ${message}`);
25
+ process.exit(1);
26
+ }
27
+
28
+ // Section summary
29
+ const sectionCount = result.sections.length;
30
+ const truncatedCount = result.truncated.length;
31
+
32
+ console.log(
33
+ ` ${chalk.cyan("\u25C6")} ${sectionCount} section${sectionCount !== 1 ? "s" : ""} generated` +
34
+ (truncatedCount > 0
35
+ ? chalk.dim(` · ${truncatedCount} truncated`)
36
+ : "")
37
+ );
38
+
39
+ // Token budget
40
+ const budgetValue = options.budget ? parseInt(options.budget, 10) : 8000;
41
+ const usedK = (result.totalTokens / 1000).toFixed(1);
42
+ const budgetK = (budgetValue / 1000).toFixed(0);
43
+ console.log(
44
+ ` ${chalk.cyan("\u25C6")} Project context: ${chalk.bold(usedK + "k")} of ${budgetK}k token budget`
45
+ );
46
+
47
+ if (options.dryRun) {
48
+ // Show section breakdown
49
+ console.log();
50
+ console.log(chalk.dim(" Section breakdown:"));
51
+ for (const section of result.sections) {
52
+ const sTokens = (section.tokens / 1000).toFixed(1);
53
+ console.log(
54
+ ` ${chalk.dim(String(section.priority).padStart(2))} ${section.title.padEnd(30)} ${chalk.dim(sTokens + "k tokens")}`
55
+ );
56
+ }
57
+ console.log();
58
+ console.log(chalk.dim(" Dry run — nothing written."));
59
+ } else {
60
+ const outputPath = getProjectClaudeMdPath(projectDir);
61
+ const shortPath = outputPath.replace(
62
+ process.env.HOME || "~",
63
+ "~"
64
+ );
65
+ console.log(
66
+ ` ${chalk.cyan("\u25C6")} Written to ${chalk.dim(shortPath)}`
67
+ );
68
+ }
69
+ }
@@ -1,19 +1,15 @@
1
1
  import { existsSync } from "fs";
2
2
  import { readFile, writeFile } from "fs/promises";
3
3
  import chalk from "chalk";
4
- import { CONFIG, thinkPath } from "../../core/config";
5
- import { addLearning } from "../../core/dedup";
6
- import { syncCommand } from "./sync";
7
-
8
- /**
9
- * Add a new learning with deduplication
10
- */
11
- export async function learnCommand(
12
- learning: string,
13
- options: { noSync?: boolean }
14
- ): Promise<void> {
4
+ import { CONFIG, thinkPath } from "../../core/config.ts";
5
+ import { addLearning, extractLearnings } from "../../core/dedup.ts";
6
+ import { generatePlugin } from "../../core/generator.ts";
7
+
8
+ export async function learnCommand(learning: string): Promise<void> {
15
9
  if (!existsSync(CONFIG.thinkDir)) {
16
- console.log(chalk.red("~/.think not found. Run `think init` first."));
10
+ console.log(
11
+ chalk.red(` ~/.think not found. Run ${chalk.bold("think setup")} first.`)
12
+ );
17
13
  process.exit(1);
18
14
  }
19
15
 
@@ -29,22 +25,27 @@ export async function learnCommand(
29
25
  const result = addLearning(content, learning);
30
26
 
31
27
  if (!result.added) {
32
- console.log(chalk.yellow("Similar learning already exists:"));
33
- console.log(chalk.dim(` "${result.similar}"`));
34
- console.log();
35
- console.log("Learning not added (duplicate detected).");
28
+ console.log(
29
+ ` ${chalk.yellow("\u25C6")} Similar learning already exists:`
30
+ );
31
+ console.log(chalk.dim(` "${result.similar}"`));
36
32
  return;
37
33
  }
38
34
 
39
35
  // Write updated content
40
36
  await writeFile(learningsPath, result.newContent);
41
37
 
42
- console.log(chalk.green("Learning added:"));
43
- console.log(chalk.dim(` "${learning}"`));
38
+ // Count total learnings
39
+ const total = extractLearnings(result.newContent).length;
44
40
 
45
- // Auto-sync unless disabled
46
- if (!options.noSync) {
47
- console.log();
48
- await syncCommand();
49
- }
41
+ console.log(
42
+ ` ${chalk.cyan("\u25C6")} Added learning (${chalk.bold(String(total))} total)`
43
+ );
44
+
45
+ // Auto-sync
46
+ await generatePlugin();
47
+
48
+ console.log(
49
+ ` ${chalk.cyan("\u25C6")} Synced ~/.claude/CLAUDE.md`
50
+ );
50
51
  }