knowns 0.8.3 → 0.8.4

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 CHANGED
@@ -30454,7 +30454,7 @@ var require_view = __commonJS({
30454
30454
  var dirname5 = path.dirname;
30455
30455
  var basename3 = path.basename;
30456
30456
  var extname = path.extname;
30457
- var join23 = path.join;
30457
+ var join24 = path.join;
30458
30458
  var resolve = path.resolve;
30459
30459
  module2.exports = View;
30460
30460
  function View(name, options2) {
@@ -30516,12 +30516,12 @@ var require_view = __commonJS({
30516
30516
  };
30517
30517
  View.prototype.resolve = function resolve2(dir, file3) {
30518
30518
  var ext = this.ext;
30519
- var path2 = join23(dir, file3);
30519
+ var path2 = join24(dir, file3);
30520
30520
  var stat3 = tryStat(path2);
30521
30521
  if (stat3 && stat3.isFile()) {
30522
30522
  return path2;
30523
30523
  }
30524
- path2 = join23(dir, basename3(file3, ext), "index" + ext);
30524
+ path2 = join24(dir, basename3(file3, ext), "index" + ext);
30525
30525
  stat3 = tryStat(path2);
30526
30526
  if (stat3 && stat3.isFile()) {
30527
30527
  return path2;
@@ -34166,7 +34166,7 @@ var require_send = __commonJS({
34166
34166
  var Stream = __require("stream");
34167
34167
  var util2 = __require("util");
34168
34168
  var extname = path.extname;
34169
- var join23 = path.join;
34169
+ var join24 = path.join;
34170
34170
  var normalize = path.normalize;
34171
34171
  var resolve = path.resolve;
34172
34172
  var sep = path.sep;
@@ -34338,7 +34338,7 @@ var require_send = __commonJS({
34338
34338
  return res;
34339
34339
  }
34340
34340
  parts = path2.split(sep);
34341
- path2 = normalize(join23(root, path2));
34341
+ path2 = normalize(join24(root, path2));
34342
34342
  } else {
34343
34343
  if (UP_PATH_REGEXP.test(path2)) {
34344
34344
  debug('malicious path "%s"', path2);
@@ -34471,7 +34471,7 @@ var require_send = __commonJS({
34471
34471
  if (err) return self.onStatError(err);
34472
34472
  return self.error(404);
34473
34473
  }
34474
- var p = join23(path2, self._index[i]);
34474
+ var p = join24(path2, self._index[i]);
34475
34475
  debug('stat "%s"', p);
34476
34476
  fs.stat(p, function(err2, stat3) {
34477
34477
  if (err2) return next(err2);
@@ -43849,8 +43849,41 @@ function checkGitExists(projectRoot) {
43849
43849
  process.exit(1);
43850
43850
  }
43851
43851
  }
43852
+ async function createMcpJsonFile(projectRoot) {
43853
+ const { writeFileSync: writeFileSync3, readFileSync: readFileSync4 } = await import("node:fs");
43854
+ const mcpJsonPath = join4(projectRoot, ".mcp.json");
43855
+ const mcpConfig = {
43856
+ mcpServers: {
43857
+ knowns: {
43858
+ command: "npx",
43859
+ args: ["-y", "knowns", "mcp"]
43860
+ }
43861
+ }
43862
+ };
43863
+ if (existsSync2(mcpJsonPath)) {
43864
+ try {
43865
+ const existing = JSON.parse(readFileSync4(mcpJsonPath, "utf-8"));
43866
+ if (existing?.mcpServers?.knowns) {
43867
+ console.log(source_default.gray(" .mcp.json already has knowns configuration"));
43868
+ return;
43869
+ }
43870
+ existing.mcpServers = {
43871
+ ...existing.mcpServers,
43872
+ ...mcpConfig.mcpServers
43873
+ };
43874
+ writeFileSync3(mcpJsonPath, JSON.stringify(existing, null, " "), "utf-8");
43875
+ console.log(source_default.green("\u2713 Added knowns to existing .mcp.json"));
43876
+ } catch {
43877
+ writeFileSync3(mcpJsonPath, JSON.stringify(mcpConfig, null, " "), "utf-8");
43878
+ console.log(source_default.green("\u2713 Created .mcp.json (replaced invalid file)"));
43879
+ }
43880
+ } else {
43881
+ writeFileSync3(mcpJsonPath, JSON.stringify(mcpConfig, null, " "), "utf-8");
43882
+ console.log(source_default.green("\u2713 Created .mcp.json for Claude Code MCP auto-discovery"));
43883
+ }
43884
+ }
43852
43885
  async function updateGitignoreForIgnoredMode(projectRoot) {
43853
- const { appendFileSync, readFileSync: readFileSync3, writeFileSync: writeFileSync2 } = await import("node:fs");
43886
+ const { appendFileSync, readFileSync: readFileSync4, writeFileSync: writeFileSync3 } = await import("node:fs");
43854
43887
  const gitignorePath = join4(projectRoot, ".gitignore");
43855
43888
  const knownsIgnorePattern = `
43856
43889
  # knowns (ignore all except docs)
@@ -43859,7 +43892,7 @@ async function updateGitignoreForIgnoredMode(projectRoot) {
43859
43892
  !.knowns/docs/**
43860
43893
  `;
43861
43894
  if (existsSync2(gitignorePath)) {
43862
- const content = readFileSync3(gitignorePath, "utf-8");
43895
+ const content = readFileSync4(gitignorePath, "utf-8");
43863
43896
  if (content.includes(".knowns/*")) {
43864
43897
  console.log(source_default.gray(" .gitignore already has knowns pattern"));
43865
43898
  return;
@@ -43867,7 +43900,7 @@ async function updateGitignoreForIgnoredMode(projectRoot) {
43867
43900
  appendFileSync(gitignorePath, knownsIgnorePattern);
43868
43901
  console.log(source_default.green("\u2713 Updated .gitignore with knowns pattern"));
43869
43902
  } else {
43870
- writeFileSync2(gitignorePath, `${knownsIgnorePattern.trim()}
43903
+ writeFileSync3(gitignorePath, `${knownsIgnorePattern.trim()}
43871
43904
  `, "utf-8");
43872
43905
  console.log(source_default.green("\u2713 Created .gitignore with knowns pattern"));
43873
43906
  }
@@ -43907,43 +43940,6 @@ async function runWizard() {
43907
43940
  initial: 0
43908
43941
  // git-tracked
43909
43942
  },
43910
- {
43911
- type: "text",
43912
- name: "defaultAssignee",
43913
- message: "Default assignee (optional)",
43914
- initial: "",
43915
- format: (value) => value.trim() ? value.trim() : void 0
43916
- },
43917
- {
43918
- type: "select",
43919
- name: "defaultPriority",
43920
- message: "Default priority for new tasks",
43921
- choices: [
43922
- { title: "Low", value: "low" },
43923
- { title: "Medium", value: "medium" },
43924
- { title: "High", value: "high" }
43925
- ],
43926
- initial: 1
43927
- // medium
43928
- },
43929
- {
43930
- type: "list",
43931
- name: "defaultLabels",
43932
- message: "Default labels (comma-separated, optional)",
43933
- initial: "",
43934
- separator: ","
43935
- },
43936
- {
43937
- type: "select",
43938
- name: "timeFormat",
43939
- message: "Time format",
43940
- choices: [
43941
- { title: "24-hour (14:30)", value: "24h" },
43942
- { title: "12-hour (2:30 PM)", value: "12h" }
43943
- ],
43944
- initial: 0
43945
- // 24h
43946
- },
43947
43943
  {
43948
43944
  type: "select",
43949
43945
  name: "guidelinesType",
@@ -43980,10 +43976,9 @@ async function runWizard() {
43980
43976
  }
43981
43977
  return {
43982
43978
  name: response.name,
43983
- defaultAssignee: response.defaultAssignee,
43984
- defaultPriority: response.defaultPriority,
43985
- defaultLabels: response.defaultLabels?.filter((l) => l.trim()) || [],
43986
- timeFormat: response.timeFormat,
43979
+ defaultPriority: "medium",
43980
+ defaultLabels: [],
43981
+ timeFormat: "24h",
43987
43982
  gitTrackingMode: response.gitTrackingMode || "git-tracked",
43988
43983
  guidelinesType: response.guidelinesType || "cli",
43989
43984
  agentFiles: response.agentFiles || []
@@ -44026,57 +44021,35 @@ var initCommand = new Command("init").description("Initialize .knowns/ folder in
44026
44021
  if (config2.gitTrackingMode === "git-ignored") {
44027
44022
  await updateGitignoreForIgnoredMode(projectRoot);
44028
44023
  }
44024
+ if (config2.guidelinesType === "mcp") {
44025
+ await createMcpJsonFile(projectRoot);
44026
+ }
44029
44027
  const fileStore2 = new FileStore(projectRoot);
44030
44028
  const project = await fileStore2.initProject(config2.name, {
44031
- defaultAssignee: config2.defaultAssignee,
44032
44029
  defaultPriority: config2.defaultPriority,
44033
44030
  defaultLabels: config2.defaultLabels,
44034
44031
  timeFormat: config2.timeFormat,
44035
44032
  gitTrackingMode: config2.gitTrackingMode
44036
44033
  });
44037
44034
  console.log();
44038
- console.log(source_default.green("\u2713 Project initialized successfully!"));
44039
- console.log(source_default.gray(` Name: ${project.name}`));
44040
- console.log(source_default.gray(` Location: ${knownsPath}`));
44041
- console.log(
44042
- source_default.gray(` Git Mode: ${config2.gitTrackingMode === "git-tracked" ? "Tracked (team)" : "Ignored (personal)"}`)
44043
- );
44044
- if (config2.defaultAssignee) {
44045
- console.log(source_default.gray(` Default Assignee: ${config2.defaultAssignee}`));
44046
- }
44047
- console.log(source_default.gray(` Default Priority: ${config2.defaultPriority}`));
44048
- if (config2.defaultLabels.length > 0) {
44049
- console.log(source_default.gray(` Default Labels: ${config2.defaultLabels.join(", ")}`));
44050
- }
44051
- console.log(source_default.gray(` Time Format: ${config2.timeFormat}`));
44052
- console.log();
44035
+ console.log(source_default.green(`\u2713 Project initialized: ${project.name}`));
44053
44036
  if (config2.agentFiles.length > 0) {
44054
44037
  const guidelines = getGuidelines(config2.guidelinesType);
44055
- console.log(source_default.bold(`Updating AI instruction files (${config2.guidelinesType.toUpperCase()} version)...`));
44056
- console.log();
44057
- let syncedCount = 0;
44058
44038
  for (const file3 of config2.agentFiles) {
44059
44039
  try {
44060
44040
  const result = await updateInstructionFile(file3.path, guidelines);
44061
44041
  if (result.success) {
44062
- syncedCount++;
44063
44042
  const action = result.action === "created" ? "Created" : result.action === "appended" ? "Appended" : "Updated";
44064
- console.log(source_default.green(`\u2713 ${action} ${file3.name}: ${file3.path}`));
44043
+ console.log(source_default.green(`\u2713 ${action}: ${file3.path}`));
44065
44044
  }
44066
- } catch (error48) {
44067
- console.log(source_default.yellow(`\u26A0\uFE0F Skipped ${file3.name}: ${file3.path}`));
44045
+ } catch {
44046
+ console.log(source_default.yellow(`\u26A0\uFE0F Skipped: ${file3.path}`));
44068
44047
  }
44069
44048
  }
44070
- console.log();
44071
- console.log(source_default.green(`\u2713 Synced guidelines to ${syncedCount} AI instruction file(s)`));
44072
- } else {
44073
- console.log(source_default.gray("Skipped AI instruction files (none selected)"));
44074
44049
  }
44075
44050
  console.log();
44076
- console.log(source_default.cyan("Next steps:"));
44077
- console.log(source_default.gray(' 1. Create a task: knowns task create "My first task"'));
44078
- console.log(source_default.gray(" 2. List tasks: knowns task list"));
44079
- console.log(source_default.gray(" 3. Open web UI: knowns browser"));
44051
+ console.log(source_default.cyan("Get started:"));
44052
+ console.log(source_default.gray(' knowns task create "My first task"'));
44080
44053
  } catch (error48) {
44081
44054
  console.error(source_default.red("\u2717 Failed to initialize project"));
44082
44055
  if (error48 instanceof Error) {
@@ -62531,6 +62504,10 @@ var resetCommand = new Command("reset").description("Reset configuration to defa
62531
62504
  });
62532
62505
  var configCommand = new Command("config").description("Manage configuration settings").addCommand(listCommand3).addCommand(getCommand).addCommand(setCommand).addCommand(resetCommand);
62533
62506
 
62507
+ // src/commands/mcp.ts
62508
+ import { existsSync as existsSync18, readFileSync as readFileSync2, writeFileSync } from "node:fs";
62509
+ import { join as join22 } from "node:path";
62510
+
62534
62511
  // src/mcp/server.ts
62535
62512
  import { existsSync as existsSync17 } from "node:fs";
62536
62513
  import { readFile as readFile15 } from "node:fs/promises";
@@ -70761,6 +70738,89 @@ if (isStandaloneServer) {
70761
70738
  }
70762
70739
 
70763
70740
  // src/commands/mcp.ts
70741
+ function getMcpConfig() {
70742
+ return {
70743
+ command: "npx",
70744
+ args: ["-y", "knowns", "mcp"]
70745
+ };
70746
+ }
70747
+ async function setupClaudeCode() {
70748
+ const { spawnSync } = await import("node:child_process");
70749
+ const claudeCheck = spawnSync("claude", ["--version"], { stdio: "pipe" });
70750
+ if (claudeCheck.status !== 0) {
70751
+ console.log(source_default.yellow("\u26A0\uFE0F Claude Code CLI not found"));
70752
+ console.log(source_default.gray(" Install Claude Code first: https://claude.ai/code"));
70753
+ console.log(source_default.gray(" After installing, run: knowns mcp setup"));
70754
+ return false;
70755
+ }
70756
+ const config2 = getMcpConfig();
70757
+ const configJson = JSON.stringify(config2);
70758
+ const result = spawnSync("claude", ["mcp", "add-json", "knowns", configJson], {
70759
+ stdio: "inherit"
70760
+ });
70761
+ if (result.status === 0) {
70762
+ console.log(source_default.green("\u2713 Added knowns MCP server to Claude Code"));
70763
+ console.log(source_default.gray(" Restart Claude Code to activate the server"));
70764
+ return true;
70765
+ }
70766
+ const altResult = spawnSync("claude", ["mcp", "add", "knowns", "--", "npx", "-y", "knowns", "mcp"], {
70767
+ stdio: "inherit"
70768
+ });
70769
+ if (altResult.status === 0) {
70770
+ console.log(source_default.green("\u2713 Added knowns MCP server to Claude Code"));
70771
+ console.log(source_default.gray(" Restart Claude Code to activate the server"));
70772
+ return true;
70773
+ }
70774
+ console.log(source_default.red("\u2717 Failed to add MCP server to Claude Code"));
70775
+ console.log(source_default.gray(" Try adding manually with:"));
70776
+ console.log(source_default.cyan(` claude mcp add-json knowns '${configJson}'`));
70777
+ return false;
70778
+ }
70779
+ function createProjectMcpJson(projectRoot) {
70780
+ const mcpJsonPath = join22(projectRoot, ".mcp.json");
70781
+ const mcpConfig = {
70782
+ mcpServers: {
70783
+ knowns: getMcpConfig()
70784
+ }
70785
+ };
70786
+ if (existsSync18(mcpJsonPath)) {
70787
+ try {
70788
+ const existing = JSON.parse(readFileSync2(mcpJsonPath, "utf-8"));
70789
+ if (existing?.mcpServers?.knowns) {
70790
+ console.log(source_default.gray(" .mcp.json already has knowns configuration"));
70791
+ return true;
70792
+ }
70793
+ existing.mcpServers = {
70794
+ ...existing.mcpServers,
70795
+ ...mcpConfig.mcpServers
70796
+ };
70797
+ writeFileSync(mcpJsonPath, JSON.stringify(existing, null, " "), "utf-8");
70798
+ console.log(source_default.green("\u2713 Added knowns to existing .mcp.json"));
70799
+ } catch {
70800
+ writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, " "), "utf-8");
70801
+ console.log(source_default.green("\u2713 Created .mcp.json (replaced invalid file)"));
70802
+ }
70803
+ } else {
70804
+ writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, " "), "utf-8");
70805
+ console.log(source_default.green("\u2713 Created .mcp.json for Claude Code project-level auto-discovery"));
70806
+ }
70807
+ return true;
70808
+ }
70809
+ var setupCommand = new Command("setup").description("Setup knowns MCP server in Claude Code").option("--project", "Only create .mcp.json in project (skip Claude Code setup)").option("--global", "Only setup in Claude Code globally (skip .mcp.json)").action(async (options2) => {
70810
+ const projectRoot = findProjectRoot();
70811
+ const doProject = options2.project || !options2.project && !options2.global;
70812
+ const doGlobal = options2.global || !options2.project && !options2.global;
70813
+ if (doProject) {
70814
+ if (projectRoot) {
70815
+ createProjectMcpJson(projectRoot);
70816
+ } else {
70817
+ console.log(source_default.yellow("\u26A0\uFE0F Not in a Knowns project. Run 'knowns init' first."));
70818
+ }
70819
+ }
70820
+ if (doGlobal) {
70821
+ await setupClaudeCode();
70822
+ }
70823
+ });
70764
70824
  var mcpCommand = new Command("mcp").description("Start MCP server for AI agent integration (Claude Desktop, etc.)").option("-v, --verbose", "Enable verbose logging").option("--info", "Show configuration instructions").action(async (options2) => {
70765
70825
  if (options2.info) {
70766
70826
  showConfigInfo();
@@ -70779,7 +70839,7 @@ var mcpCommand = new Command("mcp").description("Start MCP server for AI agent i
70779
70839
  console.error(source_default.red("Error:"), error48 instanceof Error ? error48.message : error48);
70780
70840
  process.exit(1);
70781
70841
  }
70782
- });
70842
+ }).addCommand(setupCommand);
70783
70843
  function showConfigInfo() {
70784
70844
  const configExample = {
70785
70845
  mcpServers: {
@@ -70823,10 +70883,10 @@ function showConfigInfo() {
70823
70883
  }
70824
70884
 
70825
70885
  // src/utils/update-notifier.ts
70826
- import { existsSync as existsSync18, readFileSync as readFileSync2, writeFileSync } from "node:fs";
70886
+ import { existsSync as existsSync19, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
70827
70887
  import { mkdir as mkdir10 } from "node:fs/promises";
70828
70888
  import { homedir } from "node:os";
70829
- import { dirname as dirname4, join as join22 } from "node:path";
70889
+ import { dirname as dirname4, join as join23 } from "node:path";
70830
70890
  var DEFAULT_TTL_MS = 60 * 60 * 1e3;
70831
70891
  var DEFAULT_TIMEOUT_MS = 2e3;
70832
70892
  function detectPackageManager(cwd) {
@@ -70839,10 +70899,10 @@ function detectPackageManager(cwd) {
70839
70899
  if (ua.startsWith("yarn/")) return "yarn";
70840
70900
  if (ua.startsWith("bun/")) return "bun";
70841
70901
  if (ua.startsWith("npm/")) return "npm";
70842
- if (existsSync18(join22(cwd, "pnpm-lock.yaml"))) return "pnpm";
70843
- if (existsSync18(join22(cwd, "yarn.lock"))) return "yarn";
70844
- if (existsSync18(join22(cwd, "bun.lock"))) return "bun";
70845
- if (existsSync18(join22(cwd, "package-lock.json"))) return "npm";
70902
+ if (existsSync19(join23(cwd, "pnpm-lock.yaml"))) return "pnpm";
70903
+ if (existsSync19(join23(cwd, "yarn.lock"))) return "yarn";
70904
+ if (existsSync19(join23(cwd, "bun.lock"))) return "bun";
70905
+ if (existsSync19(join23(cwd, "package-lock.json"))) return "npm";
70846
70906
  return "npm";
70847
70907
  }
70848
70908
  function compareVersions(a, b) {
@@ -70866,11 +70926,11 @@ function shouldSkip(args2, force) {
70866
70926
  }
70867
70927
  function getGlobalCachePath(explicit) {
70868
70928
  if (explicit) return explicit;
70869
- return join22(homedir(), ".knowns", "cli-cache.json");
70929
+ return join23(homedir(), ".knowns", "cli-cache.json");
70870
70930
  }
70871
70931
  function readCache(cachePath) {
70872
70932
  try {
70873
- const raw = readFileSync2(cachePath, "utf-8");
70933
+ const raw = readFileSync3(cachePath, "utf-8");
70874
70934
  const data = JSON.parse(raw);
70875
70935
  if (typeof data.lastChecked === "number" && typeof data.latestVersion === "string") {
70876
70936
  return data;
@@ -70882,10 +70942,10 @@ function readCache(cachePath) {
70882
70942
  }
70883
70943
  async function writeCache(cachePath, data) {
70884
70944
  const dir = dirname4(cachePath);
70885
- if (dir && !existsSync18(dir)) {
70945
+ if (dir && !existsSync19(dir)) {
70886
70946
  await mkdir10(dir, { recursive: true });
70887
70947
  }
70888
- writeFileSync(cachePath, JSON.stringify(data, null, 2), "utf-8");
70948
+ writeFileSync2(cachePath, JSON.stringify(data, null, 2), "utf-8");
70889
70949
  }
70890
70950
  async function fetchLatestVersion(packageName) {
70891
70951
  try {
@@ -70948,7 +71008,7 @@ async function notifyCliUpdate(options2) {
70948
71008
  // package.json
70949
71009
  var package_default = {
70950
71010
  name: "knowns",
70951
- version: "0.8.3",
71011
+ version: "0.8.4",
70952
71012
  description: "AI-native task and documentation management for dev teams",
70953
71013
  module: "index.ts",
70954
71014
  type: "module",