coding-friend-cli 1.0.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 (61) hide show
  1. package/dist/chunk-6CGGT2FD.js +32 -0
  2. package/dist/chunk-6DUFTBTO.js +14 -0
  3. package/dist/chunk-AQXTNLQD.js +39 -0
  4. package/dist/chunk-HRVSKMNA.js +31 -0
  5. package/dist/chunk-IUTXHCP7.js +28 -0
  6. package/dist/chunk-KZT4AFDW.js +44 -0
  7. package/dist/chunk-VHZQ6KEU.js +73 -0
  8. package/dist/host-3GAEZKKJ.js +83 -0
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +34 -0
  11. package/dist/init-ONRXFOZ5.js +431 -0
  12. package/dist/json-2XS56OJY.js +10 -0
  13. package/dist/mcp-LMMIFH4B.js +104 -0
  14. package/dist/postinstall.d.ts +1 -0
  15. package/dist/postinstall.js +8 -0
  16. package/dist/statusline-7D6YU5YM.js +64 -0
  17. package/dist/update-K5PYOB52.js +160 -0
  18. package/lib/learn-host/next-env.d.ts +6 -0
  19. package/lib/learn-host/next.config.ts +9 -0
  20. package/lib/learn-host/package-lock.json +3943 -0
  21. package/lib/learn-host/package.json +31 -0
  22. package/lib/learn-host/postcss.config.mjs +7 -0
  23. package/lib/learn-host/scripts/build-search-index.ts +11 -0
  24. package/lib/learn-host/src/app/[category]/[slug]/page.tsx +61 -0
  25. package/lib/learn-host/src/app/[category]/page.tsx +35 -0
  26. package/lib/learn-host/src/app/globals.css +31 -0
  27. package/lib/learn-host/src/app/layout.tsx +32 -0
  28. package/lib/learn-host/src/app/page.tsx +63 -0
  29. package/lib/learn-host/src/app/search/page.tsx +94 -0
  30. package/lib/learn-host/src/app/search/search-index.json +42 -0
  31. package/lib/learn-host/src/components/Breadcrumbs.tsx +28 -0
  32. package/lib/learn-host/src/components/DocCard.tsx +32 -0
  33. package/lib/learn-host/src/components/MarkdownRenderer.tsx +13 -0
  34. package/lib/learn-host/src/components/MobileNav.tsx +56 -0
  35. package/lib/learn-host/src/components/SearchBar.tsx +36 -0
  36. package/lib/learn-host/src/components/Sidebar.tsx +44 -0
  37. package/lib/learn-host/src/components/TagBadge.tsx +12 -0
  38. package/lib/learn-host/src/components/ThemeToggle.tsx +30 -0
  39. package/lib/learn-host/src/lib/docs.ts +113 -0
  40. package/lib/learn-host/src/lib/search.ts +27 -0
  41. package/lib/learn-host/src/lib/types.ts +31 -0
  42. package/lib/learn-host/tsconfig.json +21 -0
  43. package/lib/learn-mcp/package-lock.json +1829 -0
  44. package/lib/learn-mcp/package.json +24 -0
  45. package/lib/learn-mcp/src/bin/learn-mcp.ts +2 -0
  46. package/lib/learn-mcp/src/index.ts +17 -0
  47. package/lib/learn-mcp/src/lib/docs.ts +199 -0
  48. package/lib/learn-mcp/src/lib/knowledge.ts +95 -0
  49. package/lib/learn-mcp/src/lib/types.ts +36 -0
  50. package/lib/learn-mcp/src/server.ts +22 -0
  51. package/lib/learn-mcp/src/tools/create-doc.ts +29 -0
  52. package/lib/learn-mcp/src/tools/get-review-list.ts +29 -0
  53. package/lib/learn-mcp/src/tools/improve-doc.ts +95 -0
  54. package/lib/learn-mcp/src/tools/list-categories.ts +19 -0
  55. package/lib/learn-mcp/src/tools/list-docs.ts +30 -0
  56. package/lib/learn-mcp/src/tools/read-doc.ts +29 -0
  57. package/lib/learn-mcp/src/tools/search-docs.ts +23 -0
  58. package/lib/learn-mcp/src/tools/track-knowledge.ts +35 -0
  59. package/lib/learn-mcp/src/tools/update-doc.ts +43 -0
  60. package/lib/learn-mcp/tsconfig.json +15 -0
  61. package/package.json +47 -0
@@ -0,0 +1,160 @@
1
+ import {
2
+ ensureShellCompletion
3
+ } from "./chunk-VHZQ6KEU.js";
4
+ import {
5
+ commandExists,
6
+ run
7
+ } from "./chunk-6CGGT2FD.js";
8
+ import {
9
+ claudeSettingsPath,
10
+ installedPluginsPath,
11
+ pluginCachePath
12
+ } from "./chunk-AQXTNLQD.js";
13
+ import {
14
+ log
15
+ } from "./chunk-6DUFTBTO.js";
16
+ import {
17
+ readJson,
18
+ writeJson
19
+ } from "./chunk-IUTXHCP7.js";
20
+
21
+ // src/commands/update.ts
22
+ import { existsSync, readdirSync } from "fs";
23
+ import chalk from "chalk";
24
+ function getInstalledVersion() {
25
+ const data = readJson(installedPluginsPath());
26
+ if (!data) return null;
27
+ const plugins = data.plugins ?? data;
28
+ for (const [key, value] of Object.entries(plugins)) {
29
+ if (!key.includes("coding-friend")) continue;
30
+ if (Array.isArray(value) && value.length > 0) {
31
+ const entry = value[0];
32
+ if (typeof entry.version === "string") return entry.version;
33
+ }
34
+ if (typeof value === "object" && value !== null && "version" in value) {
35
+ return value.version;
36
+ }
37
+ }
38
+ return null;
39
+ }
40
+ function getLatestVersion() {
41
+ let tag = run("gh", [
42
+ "api",
43
+ "repos/dinhanhthi/coding-friend/releases/latest",
44
+ "--jq",
45
+ ".tag_name"
46
+ ]);
47
+ if (!tag) {
48
+ const json = run("curl", [
49
+ "-s",
50
+ "https://api.github.com/repos/dinhanhthi/coding-friend/releases/latest"
51
+ ]);
52
+ if (json) {
53
+ try {
54
+ const data = JSON.parse(json);
55
+ tag = data.tag_name;
56
+ } catch {
57
+ }
58
+ }
59
+ }
60
+ if (!tag) return null;
61
+ return tag.replace(/^v/, "");
62
+ }
63
+ function getStatuslineVersion() {
64
+ const settings = readJson(claudeSettingsPath());
65
+ if (!settings?.statusLine) return null;
66
+ const sl = settings.statusLine;
67
+ if (!sl.command) return null;
68
+ const match = sl.command.match(
69
+ /coding-friend-marketplace\/coding-friend\/([^/]+)\//
70
+ );
71
+ return match?.[1] ?? null;
72
+ }
73
+ function findLatestCacheVersion() {
74
+ const cachePath = pluginCachePath();
75
+ if (!existsSync(cachePath)) return null;
76
+ const versions = readdirSync(cachePath, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort().reverse();
77
+ return versions[0] ?? null;
78
+ }
79
+ function updateStatusline(version) {
80
+ const cachePath = pluginCachePath();
81
+ const hookPath = `${cachePath}/${version}/hooks/statusline.sh`;
82
+ if (!existsSync(hookPath)) {
83
+ log.warn(`Statusline hook not found for v${version}`);
84
+ return false;
85
+ }
86
+ const settingsPath = claudeSettingsPath();
87
+ const settings = readJson(settingsPath) ?? {};
88
+ settings.statusLine = {
89
+ type: "command",
90
+ command: `bash ${hookPath}`
91
+ };
92
+ writeJson(settingsPath, settings);
93
+ return true;
94
+ }
95
+ async function updateCommand() {
96
+ console.log("=== \u{1F33F} Coding Friend Update \u{1F33F} ===");
97
+ console.log();
98
+ const currentVersion = getInstalledVersion();
99
+ const latestVersion = getLatestVersion();
100
+ const statuslineVersion = getStatuslineVersion();
101
+ log.info(`Installed version: ${currentVersion ? chalk.green(`v${currentVersion}`) : chalk.yellow("not found")}`);
102
+ log.info(`Latest version: ${latestVersion ? chalk.green(`v${latestVersion}`) : chalk.yellow("unknown (cannot reach GitHub)")}`);
103
+ log.info(
104
+ `Statusline version: ${statuslineVersion ? chalk.green(`v${statuslineVersion}`) : chalk.yellow("not configured")}`
105
+ );
106
+ console.log();
107
+ if (!latestVersion) {
108
+ log.warn(
109
+ "Cannot check latest version. Verify manually at https://github.com/dinhanhthi/coding-friend/releases"
110
+ );
111
+ return;
112
+ }
113
+ const isUpToDate = currentVersion === latestVersion;
114
+ const statuslineMismatch = statuslineVersion !== null && statuslineVersion !== (currentVersion ?? latestVersion);
115
+ if (isUpToDate && !statuslineMismatch) {
116
+ log.success(`Already on the latest version (${chalk.green(`v${latestVersion}`)}). No update needed.`);
117
+ return;
118
+ }
119
+ if (!isUpToDate) {
120
+ log.step(`Update available: ${chalk.yellow(`v${currentVersion}`)} \u2192 ${chalk.green(`v${latestVersion}`)}`);
121
+ if (!commandExists("claude")) {
122
+ log.error(
123
+ "Claude CLI not found. Install it first, or run: claude plugin update coding-friend@coding-friend-marketplace"
124
+ );
125
+ return;
126
+ }
127
+ log.step("Updating plugin...");
128
+ const result = run("claude", [
129
+ "plugin",
130
+ "update",
131
+ "coding-friend@coding-friend-marketplace"
132
+ ]);
133
+ if (result === null) {
134
+ log.error("Plugin update failed. Try manually: claude plugin update coding-friend@coding-friend-marketplace");
135
+ return;
136
+ }
137
+ log.success("Plugin updated!");
138
+ const newVersion = getInstalledVersion();
139
+ if (newVersion === currentVersion) {
140
+ log.warn(
141
+ "Version unchanged after update. Restart Claude Code and try cf update again."
142
+ );
143
+ return;
144
+ }
145
+ log.success(`Updated to ${chalk.green(`v${newVersion}`)}`);
146
+ }
147
+ const targetVersion = findLatestCacheVersion();
148
+ if (targetVersion) {
149
+ log.step("Updating statusline...");
150
+ if (updateStatusline(targetVersion)) {
151
+ log.success(`Statusline updated to ${chalk.green(`v${targetVersion}`)}`);
152
+ }
153
+ }
154
+ ensureShellCompletion({ silent: false });
155
+ console.log();
156
+ log.dim("Restart Claude Code (or start a new session) to see changes.");
157
+ }
158
+ export {
159
+ updateCommand
160
+ };
@@ -0,0 +1,6 @@
1
+ /// <reference types="next" />
2
+ /// <reference types="next/image-types/global" />
3
+ /// <reference path="./.next/types/routes.d.ts" />
4
+
5
+ // NOTE: This file should not be edited
6
+ // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
@@ -0,0 +1,9 @@
1
+ import type { NextConfig } from "next";
2
+
3
+ const nextConfig: NextConfig = {
4
+ output: "export",
5
+ trailingSlash: true,
6
+ images: { unoptimized: true },
7
+ };
8
+
9
+ export default nextConfig;