@danielblomma/cortex-mcp 2.0.18 → 2.0.19

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/README.md CHANGED
@@ -97,7 +97,7 @@ cortex init --bootstrap
97
97
 
98
98
  This will:
99
99
 
100
- - scaffold `.context/`, `scripts/`, `mcp/`, `.githooks/`, and docs files
100
+ - scaffold `.context/`, `.context/scripts/`, `.context/mcp/`, `.githooks/`, and docs files
101
101
  - activate git hooks for checkout, pull/merge, commit, and rewrite events
102
102
  - build and prepare the local MCP server
103
103
  - try to auto-register MCP connections for Claude/Codex (if installed)
package/bin/cortex.mjs CHANGED
@@ -27,11 +27,14 @@ const PACKAGE_JSON_PATH = path.join(PACKAGE_ROOT, "package.json");
27
27
  // only the three editable config files". Generated artifacts (db,
28
28
  // embeddings, cache, hooks, mcp/, govern.local.json) never land in git.
29
29
  const MCP_PROJECT_REL = path.join(".context", "mcp");
30
+ const CONTEXT_SCRIPTS_REL = path.join(".context", "scripts");
30
31
 
32
+ // `.context/*` (not `.context/`) so the !-negations below actually re-include
33
+ // the config files — git can't re-include children of an excluded directory.
31
34
  const GITIGNORE_LINES = [
32
35
  "",
33
36
  "# Cortex local storage",
34
- ".context/",
37
+ ".context/*",
35
38
  "!.context/config.yaml",
36
39
  "!.context/rules.yaml",
37
40
  "!.context/ontology.cypher",
@@ -461,12 +464,73 @@ function migrateLegacyMcpLocation(targetDir) {
461
464
  );
462
465
  }
463
466
 
467
+ const LEGACY_SCRIPT_ENTRIES = [
468
+ "bootstrap.sh",
469
+ "context.sh",
470
+ "dashboard.mjs",
471
+ "dashboard.sh",
472
+ "doctor.sh",
473
+ "embed.sh",
474
+ "ingest.mjs",
475
+ "ingest.sh",
476
+ "install-git-hooks.sh",
477
+ "load-kuzu.sh",
478
+ "load-ryu.sh",
479
+ "memory-compile.mjs",
480
+ "memory-compile.sh",
481
+ "memory-lint.mjs",
482
+ "memory-lint.sh",
483
+ "refresh.sh",
484
+ "status.sh",
485
+ "update-context.sh",
486
+ "watch.sh",
487
+ "lib",
488
+ "parsers"
489
+ ];
490
+
491
+ function looksLikeLegacyCortexScriptsDir(scriptsDir) {
492
+ const contextScript = path.join(scriptsDir, "context.sh");
493
+ if (!fs.existsSync(contextScript)) {
494
+ return false;
495
+ }
496
+ try {
497
+ const contents = fs.readFileSync(contextScript, "utf8");
498
+ return contents.includes("bootstrap)") && contents.includes("graph-load)") && contents.includes("memory-lint)");
499
+ } catch {
500
+ return false;
501
+ }
502
+ }
503
+
504
+ function removeLegacyCortexScripts(targetDir) {
505
+ if (path.resolve(targetDir) === PACKAGE_ROOT) {
506
+ return;
507
+ }
508
+
509
+ const scriptsDir = path.join(targetDir, "scripts");
510
+ if (!looksLikeLegacyCortexScriptsDir(scriptsDir)) {
511
+ return;
512
+ }
513
+
514
+ for (const entry of LEGACY_SCRIPT_ENTRIES) {
515
+ fs.rmSync(path.join(scriptsDir, entry), { recursive: true, force: true });
516
+ }
517
+
518
+ try {
519
+ if (fs.existsSync(scriptsDir) && fs.readdirSync(scriptsDir).length === 0) {
520
+ fs.rmdirSync(scriptsDir);
521
+ }
522
+ } catch {
523
+ // Best effort. A user's own files in scripts/ must remain untouched.
524
+ }
525
+ }
526
+
464
527
  function installScaffold(targetDir, force) {
465
528
  migrateLegacyMcpLocation(targetDir);
529
+ removeLegacyCortexScripts(targetDir);
466
530
 
467
531
  const copyMap = [
468
532
  [path.join(SCAFFOLD_ROOT, ".context"), path.join(targetDir, ".context")],
469
- [path.join(SCAFFOLD_ROOT, "scripts"), path.join(targetDir, "scripts")],
533
+ [path.join(SCAFFOLD_ROOT, "scripts"), path.join(targetDir, CONTEXT_SCRIPTS_REL)],
470
534
  [path.join(SCAFFOLD_ROOT, "mcp"), path.join(targetDir, MCP_PROJECT_REL)],
471
535
  [path.join(SCAFFOLD_ROOT, ".githooks"), path.join(targetDir, ".githooks")]
472
536
  ];
@@ -720,7 +784,7 @@ async function connectMcpClients(targetDir, options = {}) {
720
784
  }
721
785
 
722
786
  async function maybeInstallGitHooks(targetDir) {
723
- const installScript = path.join(targetDir, "scripts", "install-git-hooks.sh");
787
+ const installScript = path.join(targetDir, CONTEXT_SCRIPTS_REL, "install-git-hooks.sh");
724
788
  if (!fs.existsSync(installScript)) {
725
789
  return false;
726
790
  }
@@ -758,16 +822,17 @@ function isTruthyEnv(value) {
758
822
  function canAutoInitialize(targetDir) {
759
823
  // Legacy mcp/ at root no longer counted — pre-v2.0.5 projects are migrated
760
824
  // by installScaffold rather than blocking auto-init.
761
- const scaffoldPaths = [".context", "scripts", ".githooks"].map((entry) => path.join(targetDir, entry));
825
+ const scaffoldPaths = [".context", ".githooks"].map((entry) => path.join(targetDir, entry));
762
826
  return scaffoldPaths.every((entryPath) => !fs.existsSync(entryPath));
763
827
  }
764
828
 
765
829
  function isScaffoldOutOfDate(targetDir) {
766
- const contextScript = path.join(targetDir, "scripts", "context.sh");
830
+ const contextScript = path.join(targetDir, CONTEXT_SCRIPTS_REL, "context.sh");
831
+ const legacyContextScript = path.join(targetDir, "scripts", "context.sh");
767
832
  if (!fs.existsSync(contextScript)) {
768
- return false;
833
+ return fs.existsSync(legacyContextScript);
769
834
  }
770
- const doctorScript = path.join(targetDir, "scripts", "doctor.sh");
835
+ const doctorScript = path.join(targetDir, CONTEXT_SCRIPTS_REL, "doctor.sh");
771
836
  if (!fs.existsSync(doctorScript)) {
772
837
  return true;
773
838
  }
@@ -812,7 +877,7 @@ async function maybeMigrateScaffold(targetDir, command) {
812
877
 
813
878
  console.error(
814
879
  `[cortex] scaffold in ${targetDir} is out of date ` +
815
- `(missing scripts/doctor.sh, .context/mcp/package.json, doctor subcommand in context.sh, ` +
880
+ `(missing .context/scripts/doctor.sh, .context/mcp/package.json, doctor subcommand in context.sh, ` +
816
881
  `or carries a legacy mcp/ directory at the project root).`
817
882
  );
818
883
 
@@ -881,7 +946,7 @@ async function ensureProjectInitializedForMcp(targetDir) {
881
946
  }
882
947
 
883
948
  async function runContextCommand(cwd, contextArgs) {
884
- const contextScript = path.join(cwd, "scripts", "context.sh");
949
+ const contextScript = path.join(cwd, CONTEXT_SCRIPTS_REL, "context.sh");
885
950
  if (!fs.existsSync(contextScript)) {
886
951
  throw new Error(`Missing ${contextScript}. Run 'cortex init' first.`);
887
952
  }
@@ -915,7 +980,7 @@ async function run() {
915
980
  await maybeInstallGitHooks(target);
916
981
 
917
982
  console.log(`[cortex] initialized in ${target}`);
918
- console.log("[cortex] scaffold copied: .context/, scripts/, mcp/, .githooks/, docs/");
983
+ console.log("[cortex] scaffold copied: .context/, .context/scripts/, .context/mcp/, .githooks/, docs/");
919
984
  console.log(`[cortex] Claude commands ready: /context-update (${helpers.claude.total} files)`);
920
985
  if (helpers.codex.changed) {
921
986
  console.log("[cortex] Codex workflow instructions added to AGENTS.md");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielblomma/cortex-mcp",
3
3
  "mcpName": "io.github.DanielBlomma/cortex",
4
- "version": "2.0.18",
4
+ "version": "2.0.19",
5
5
  "description": "Local, repo-scoped context platform for coding assistants. Semantic search, graph relationships, and architectural rule context.",
6
6
  "type": "module",
7
7
  "author": "Daniel Blomma",
@@ -49,6 +49,7 @@
49
49
  "docs/MCP_MARKETPLACE.md"
50
50
  ],
51
51
  "scripts": {
52
+ "pretest": "test -d scaffold/scripts/parsers/node_modules || npm --prefix scaffold/scripts/parsers install --no-fund --no-update-notifier --silent",
52
53
  "test": "node tests/context-regressions.test.mjs && node --test tests/ingest-units.test.mjs tests/javascript-parser.test.mjs tests/sql-parser.test.mjs tests/config-parser.test.mjs tests/resources-parser.test.mjs tests/vbnet-parser.test.mjs tests/cpp-parser.test.mjs tests/dashboard.test.mjs tests/init-config.test.mjs tests/init-agents.test.mjs tests/multi-level.test.mjs tests/no-legacy-paths.test.mjs tests/tree-sitter-error-reporting.test.mjs tests/tree-sitter-body-cap.test.mjs tests/tree-sitter-exported.test.mjs tests/tree-sitter-robustness.test.mjs",
53
54
  "release:sync-version": "node scripts/sync-release-version.mjs",
54
55
  "release:check-version-sync": "node scripts/sync-release-version.mjs --check",
@@ -1,11 +1,10 @@
1
1
  repo_id: cortex
2
2
  source_paths:
3
- - src
3
+ - scripts
4
+ - mcp/src
4
5
  - docs
5
- - design
6
6
  - .context/notes
7
7
  - .context/decisions
8
- - README.md
9
8
  truth_order:
10
9
  - ADR
11
10
  - RULE
@@ -6,12 +6,12 @@ if [[ -z "$REPO_ROOT" ]]; then
6
6
  exit 0
7
7
  fi
8
8
 
9
- CONTEXT_SCRIPT="$REPO_ROOT/scripts/context.sh"
9
+ CONTEXT_SCRIPT="$REPO_ROOT/.context/scripts/context.sh"
10
10
  if [[ ! -x "$CONTEXT_SCRIPT" ]]; then
11
11
  exit 0
12
12
  fi
13
13
 
14
- PARSER_MODULES_DIR="$REPO_ROOT/scripts/parsers/node_modules"
14
+ PARSER_MODULES_DIR="$REPO_ROOT/.context/scripts/parsers/node_modules"
15
15
 
16
16
  HOOK_DIR="$REPO_ROOT/.context/hooks"
17
17
  LOCK_DIR="$HOOK_DIR/update.lock"
@@ -101,7 +101,7 @@ export function loadEmbeddingIndex(): EmbeddingIndex {
101
101
  embeddingsCache = {
102
102
  model: null,
103
103
  vectors: new Map(),
104
- warning: "Embedding index missing (run: ./scripts/context.sh embed)"
104
+ warning: "Embedding index missing (run: cortex embed)"
105
105
  };
106
106
  return embeddingsCache;
107
107
  }
@@ -419,8 +419,8 @@ function readGraphSignature(): string | null {
419
419
 
420
420
  function buildMissingDbMessage(): string {
421
421
  const dbDir = path.dirname(DB_PATH);
422
- const loadCommand = "./scripts/context.sh graph-load";
423
- const bootstrapCommand = "./scripts/context.sh bootstrap";
422
+ const loadCommand = "cortex graph-load";
423
+ const bootstrapCommand = "cortex bootstrap";
424
424
 
425
425
  if (!fs.existsSync(dbDir)) {
426
426
  return `RyuGraph directory missing at ${dbDir}. Run ${bootstrapCommand}.`;
@@ -430,7 +430,7 @@ function buildMissingDbMessage(): string {
430
430
  }
431
431
 
432
432
  function buildIncompatibleGraphMessage(missingKeys: string[]): string {
433
- const loadCommand = "./scripts/context.sh graph-load";
433
+ const loadCommand = "cortex graph-load";
434
434
  const missing = missingKeys.join(", ");
435
435
  return `RyuGraph manifest is missing schema keys (${missing}). Run ${loadCommand} to rebuild the graph DB.`;
436
436
  }
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
5
6
  MCP_DIR="$REPO_ROOT/.context/mcp"
6
7
  TOTAL_STEPS=6
7
8
  STEP_INDEX=0
@@ -25,24 +26,24 @@ mkdir -p "$MCP_DIR/.npm-cache"
25
26
  step "Installing MCP dependencies"
26
27
  info "note: upstream RyuGraph dependencies may print deprecation warnings during install"
27
28
  NPM_CONFIG_CACHE="$MCP_DIR/.npm-cache" npm --prefix "$MCP_DIR" install --no-fund --no-update-notifier --loglevel=warn
28
- NPM_CONFIG_CACHE="$REPO_ROOT/scripts/parsers/.npm-cache" npm --prefix "$REPO_ROOT/scripts/parsers" install --no-fund --no-update-notifier --loglevel=warn
29
+ NPM_CONFIG_CACHE="$REPO_ROOT/.context/scripts/parsers/.npm-cache" npm --prefix "$REPO_ROOT/.context/scripts/parsers" install --no-fund --no-update-notifier --loglevel=warn
29
30
 
30
- source "$REPO_ROOT/scripts/lib/enterprise-check.sh"
31
+ source "$SCRIPT_DIR/lib/enterprise-check.sh"
31
32
 
32
33
  step "Indexing repository context"
33
- "$REPO_ROOT/scripts/ingest.sh"
34
+ "$SCRIPT_DIR/ingest.sh"
34
35
 
35
36
  step "Generating semantic embeddings"
36
- if ! "$REPO_ROOT/scripts/embed.sh"; then
37
+ if ! "$SCRIPT_DIR/embed.sh"; then
37
38
  info "warning: embedding generation failed; continuing with lexical search fallback"
38
39
  fi
39
40
 
40
41
  step "Loading RyuGraph"
41
- "$REPO_ROOT/scripts/load-ryu.sh"
42
+ "$SCRIPT_DIR/load-ryu.sh"
42
43
 
43
44
  step "Reading context status"
44
- "$REPO_ROOT/scripts/status.sh"
45
+ "$SCRIPT_DIR/status.sh"
45
46
 
46
47
  echo ""
47
48
  info "bootstrap complete"
48
- info "next: run ./scripts/context.sh update while coding"
49
+ info "next: run cortex update while coding"
@@ -5,7 +5,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
5
 
6
6
  print_help() {
7
7
  cat <<'EOF'
8
- Usage: ./scripts/context.sh <command> [options]
8
+ Usage: cortex <command> [options]
9
9
 
10
10
  Commands:
11
11
  bootstrap Install deps + full ingest + graph load
@@ -6,7 +6,9 @@ import { execSync } from "node:child_process";
6
6
 
7
7
  const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = path.dirname(__filename);
9
- const REPO_ROOT = path.resolve(__dirname, "..");
9
+ const REPO_ROOT = process.env.CORTEX_PROJECT_ROOT
10
+ ? path.resolve(process.env.CORTEX_PROJECT_ROOT)
11
+ : path.resolve(__dirname, "..", "..");
10
12
  const CONTEXT_DIR = path.join(REPO_ROOT, ".context");
11
13
  const CACHE_DIR = path.join(CONTEXT_DIR, "cache");
12
14
  const CONFIG_PATH = path.join(CONTEXT_DIR, "config.yaml");
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4
- REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
4
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
5
5
  MANIFEST="$REPO_ROOT/.context/cache/manifest.json"
6
6
 
7
7
  if [[ ! -f "$MANIFEST" ]]; then
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
5
6
  CONTEXT_DIR="$REPO_ROOT/.context"
6
7
  MCP_DIR="$CONTEXT_DIR/mcp"
7
8
 
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
5
6
  MCP_DIR="$REPO_ROOT/.context/mcp"
6
7
 
7
8
  if ! command -v npm >/dev/null 2>&1; then
@@ -91,7 +91,9 @@ async function loadOptionalParsers() {
91
91
 
92
92
  const __filename = fileURLToPath(import.meta.url);
93
93
  const __dirname = path.dirname(__filename);
94
- const REPO_ROOT = path.resolve(__dirname, "..");
94
+ const REPO_ROOT = process.env.CORTEX_PROJECT_ROOT
95
+ ? path.resolve(process.env.CORTEX_PROJECT_ROOT)
96
+ : path.resolve(__dirname, "..", "..");
95
97
  const CONTEXT_DIR = path.join(REPO_ROOT, ".context");
96
98
  const CACHE_DIR = path.join(CONTEXT_DIR, "cache");
97
99
  const DB_IMPORT_DIR = path.join(CONTEXT_DIR, "db", "import");
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
5
6
  CONTEXT_DIR="$REPO_ROOT/.context"
6
7
 
7
8
  printf "[ingest] repo: %s\n" "$REPO_ROOT"
@@ -17,4 +18,4 @@ if ! command -v node >/dev/null 2>&1; then
17
18
  exit 1
18
19
  fi
19
20
 
20
- node "$REPO_ROOT/scripts/ingest.mjs" "$@"
21
+ node "$SCRIPT_DIR/ingest.mjs" "$@"
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
5
6
  HOOKS_DIR="$REPO_ROOT/.githooks"
6
7
 
7
8
  if [[ ! -d "$HOOKS_DIR" ]]; then
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
5
  echo "[graph-load] warning: load-kuzu.sh is deprecated; using RyuGraph loader"
6
- "$REPO_ROOT/scripts/load-ryu.sh" "$@"
6
+ "$SCRIPT_DIR/load-ryu.sh" "$@"
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
5
6
  MCP_DIR="$REPO_ROOT/.context/mcp"
6
7
 
7
8
  if [[ ! -f "$MCP_DIR/package.json" ]]; then
@@ -2,7 +2,7 @@
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
- import { parseFrontmatter, parseStringList } from "../.context/mcp/dist/frontmatter.js";
5
+ import { parseFrontmatter, parseStringList } from "../mcp/dist/frontmatter.js";
6
6
 
7
7
  const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = path.dirname(__filename);
@@ -17,7 +17,7 @@ function normalizeForWsl(rawPath) {
17
17
 
18
18
  const REPO_ROOT = process.env.CORTEX_PROJECT_ROOT
19
19
  ? path.resolve(normalizeForWsl(process.env.CORTEX_PROJECT_ROOT))
20
- : path.resolve(__dirname, "..");
20
+ : path.resolve(__dirname, "..", "..");
21
21
  const CONTEXT_DIR = path.join(REPO_ROOT, ".context");
22
22
  const MEMORY_DIR = path.join(CONTEXT_DIR, "memory");
23
23
  const RAW_DIR = path.join(MEMORY_DIR, "raw");
@@ -2,7 +2,8 @@
2
2
  # Keep in sync with scripts/memory-compile.sh
3
3
  set -euo pipefail
4
4
 
5
- REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
6
7
  CONTEXT_DIR="$REPO_ROOT/.context"
7
8
 
8
9
  printf "[memory-compile] repo: %s\n" "$REPO_ROOT"
@@ -17,4 +18,4 @@ if ! command -v node >/dev/null 2>&1; then
17
18
  exit 1
18
19
  fi
19
20
 
20
- node "$REPO_ROOT/scripts/memory-compile.mjs" "$@"
21
+ CORTEX_PROJECT_ROOT="$REPO_ROOT" node "$SCRIPT_DIR/memory-compile.mjs" "$@"
@@ -2,7 +2,7 @@
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
- import { parseFrontmatter, parseStringList } from "../.context/mcp/dist/frontmatter.js";
5
+ import { parseFrontmatter, parseStringList } from "../mcp/dist/frontmatter.js";
6
6
 
7
7
  const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = path.dirname(__filename);
@@ -17,7 +17,7 @@ function normalizeForWsl(rawPath) {
17
17
 
18
18
  const REPO_ROOT = process.env.CORTEX_PROJECT_ROOT
19
19
  ? path.resolve(normalizeForWsl(process.env.CORTEX_PROJECT_ROOT))
20
- : path.resolve(__dirname, "..");
20
+ : path.resolve(__dirname, "..", "..");
21
21
  const CONTEXT_DIR = path.join(REPO_ROOT, ".context");
22
22
  const MEMORY_DIR = path.join(CONTEXT_DIR, "memory");
23
23
  const COMPILED_DIR = path.join(MEMORY_DIR, "compiled");
@@ -2,7 +2,8 @@
2
2
  # Keep in sync with scripts/memory-lint.sh
3
3
  set -euo pipefail
4
4
 
5
- REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
6
7
  CONTEXT_DIR="$REPO_ROOT/.context"
7
8
 
8
9
  printf "[memory-lint] repo: %s\n" "$REPO_ROOT"
@@ -17,4 +18,4 @@ if ! command -v node >/dev/null 2>&1; then
17
18
  exit 1
18
19
  fi
19
20
 
20
- node "$REPO_ROOT/scripts/memory-lint.mjs" "$@"
21
+ CORTEX_PROJECT_ROOT="$REPO_ROOT" node "$SCRIPT_DIR/memory-lint.mjs" "$@"
@@ -21,7 +21,6 @@
21
21
  "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz",
22
22
  "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
23
23
  "license": "MIT",
24
- "peer": true,
25
24
  "bin": {
26
25
  "acorn": "bin/acorn"
27
26
  },
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
5
 
6
6
  echo "[refresh] running ingestion"
7
- "$REPO_ROOT/scripts/ingest.sh" "$@"
7
+ "$SCRIPT_DIR/ingest.sh" "$@"
8
8
 
9
9
  echo "[refresh] done"
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
5
6
  MANIFEST="$REPO_ROOT/.context/cache/manifest.json"
6
7
  GRAPH_MANIFEST="$REPO_ROOT/.context/cache/graph-manifest.json"
7
8
  EMBED_MANIFEST="$REPO_ROOT/.context/embeddings/manifest.json"
8
9
 
9
10
  if [[ ! -f "$MANIFEST" ]]; then
10
11
  echo "[status] No ingest manifest found."
11
- echo "[status] Run: ./scripts/context.sh ingest"
12
+ echo "[status] Run: cortex ingest"
12
13
  exit 0
13
14
  fi
14
15
 
@@ -47,7 +48,7 @@ console.log(`[status] graph files=${c.files ?? 0} rules=${c.rules ?? 0} adrs=${c
47
48
  console.log(`[status] graph rels constrains=${c.constrains ?? 0} implements=${c.implements ?? 0} supersedes=${c.supersedes ?? 0}`);
48
49
  ' "$GRAPH_MANIFEST"
49
50
  else
50
- echo "[status] graph manifest missing (run: ./scripts/context.sh graph-load)"
51
+ echo "[status] graph manifest missing (run: cortex graph-load)"
51
52
  fi
52
53
 
53
54
  if [[ -f "$EMBED_MANIFEST" ]]; then
@@ -68,13 +69,13 @@ if (embedded > 0 && output > 0 && failed === 0) {
68
69
  } else if (embedded > 0 && output > 0) {
69
70
  console.log(`[status] semantic_search=embedding+lexical-partial (failed=${failed})`);
70
71
  } else if (entities > 0) {
71
- console.log("[status] semantic_search=lexical-only (run: ./scripts/context.sh embed)");
72
+ console.log("[status] semantic_search=lexical-only (run: cortex embed)");
72
73
  } else {
73
74
  console.log("[status] semantic_search=lexical-only (no indexed entities)");
74
75
  }
75
76
  ' "$EMBED_MANIFEST"
76
77
  else
77
- echo "[status] embeddings manifest missing (run: ./scripts/context.sh embed)"
78
+ echo "[status] embeddings manifest missing (run: cortex embed)"
78
79
  echo "[status] semantic_search=lexical-only (embeddings manifest missing)"
79
80
  fi
80
81
 
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
5
 
6
6
  echo "[update] ingesting changed files"
7
- "$REPO_ROOT/scripts/ingest.sh" --changed
7
+ "$SCRIPT_DIR/ingest.sh" --changed
8
8
 
9
9
  echo "[update] embedding changed entities"
10
- if ! "$REPO_ROOT/scripts/embed.sh" --changed; then
10
+ if ! "$SCRIPT_DIR/embed.sh" --changed; then
11
11
  echo "[update] warning: embedding generation failed; continuing with lexical search fallback"
12
12
  fi
13
13
 
14
14
  echo "[update] rebuilding graph"
15
- "$REPO_ROOT/scripts/load-ryu.sh"
15
+ "$SCRIPT_DIR/load-ryu.sh"
16
16
 
17
17
  echo "[update] status"
18
- "$REPO_ROOT/scripts/status.sh"
18
+ "$SCRIPT_DIR/status.sh"
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
5
6
  WATCH_DIR="$REPO_ROOT/.context/watch"
6
7
  PID_FILE="$WATCH_DIR/watch.pid"
7
8
  STAMP_FILE="$WATCH_DIR/last-stamp.sha1"
@@ -21,7 +22,7 @@ EVENT_BACKEND=""
21
22
 
22
23
  print_usage() {
23
24
  cat <<'USAGE'
24
- Usage: ./scripts/watch.sh [start|stop|status|run|once] [--interval <sec>] [--debounce <sec>] [--mode <auto|event|poll>]
25
+ Usage: cortex watch [start|stop|status|run|once] [--interval <sec>] [--debounce <sec>] [--mode <auto|event|poll>]
25
26
 
26
27
  Commands:
27
28
  start Start background watch loop
@@ -149,8 +150,8 @@ status_digest() {
149
150
  # .context/ excludes the relocated .context/mcp/ tree as well.
150
151
  find "$REPO_ROOT" -type f \
151
152
  ! -path "$REPO_ROOT/.context/*" \
152
- ! -path "$REPO_ROOT/scripts/parsers/node_modules/*" \
153
- ! -path "$REPO_ROOT/scripts/parsers/.npm-cache/*" \
153
+ ! -path "$REPO_ROOT/.context/scripts/parsers/node_modules/*" \
154
+ ! -path "$REPO_ROOT/.context/scripts/parsers/.npm-cache/*" \
154
155
  -print \
155
156
  | LC_ALL=C sort \
156
157
  | shasum -a 1 \
@@ -162,7 +163,7 @@ run_update() {
162
163
  start_ts="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
163
164
  echo "[watch] update start at $start_ts"
164
165
 
165
- if bash "$REPO_ROOT/scripts/context.sh" update; then
166
+ if bash "$SCRIPT_DIR/context.sh" update; then
166
167
  echo "[watch] update success"
167
168
  return 0
168
169
  fi
@@ -199,15 +200,13 @@ wait_for_change_event() {
199
200
  inotifywait)
200
201
  inotifywait -q -r \
201
202
  -e modify,create,delete,move \
202
- --exclude '(^|/)\\.git(/|$)|(^|/)\\.context(/|$)|(^|/)scripts/parsers/(node_modules|\\.npm-cache)(/|$)' \
203
+ --exclude '(^|/)\\.git(/|$)|(^|/)\\.context(/|$)' \
203
204
  "$REPO_ROOT" >/dev/null 2>&1 || true
204
205
  ;;
205
206
  fswatch)
206
207
  fswatch -1 -r \
207
208
  --exclude '(^|/)\\.git(/|$)' \
208
209
  --exclude '(^|/)\\.context(/|$)' \
209
- --exclude '(^|/)scripts/parsers/node_modules(/|$)' \
210
- --exclude '(^|/)scripts/parsers/\\.npm-cache(/|$)' \
211
210
  "$REPO_ROOT" >/dev/null 2>&1 || true
212
211
  ;;
213
212
  *)