@prover-coder-ai/context-doc 1.0.6 → 1.0.8

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
@@ -1,13 +1,21 @@
1
1
  # Knowledge Sync CLI
2
2
 
3
- Command: `npm run sync:knowledge` (or `knowledge-sync` when installed globally) — copies project dialogs into `.knowledge` for both Codex and Qwen.
3
+ Command: `npx @prover-coder-ai/context-doc [flags]` (or `context-doc` when installed globally) — copies project dialogs into `.knowledge` for both Codex and Qwen.
4
4
 
5
5
  ## Installation (global CLI)
6
6
  - Install: `npm install -g @prover-coder-ai/context-doc`
7
7
  - Registry page: https://www.npmjs.com/package/@prover-coder-ai/context-doc
8
- - Run globally: `knowledge-sync [flags]`
8
+ - Run globally: `context-doc [flags]`
9
+ - Ad-hoc (no install): `npx @prover-coder-ai/context-doc [flags]`
9
10
  - Local (without global install): `npm run sync:knowledge` or `tsx src/shell/syncKnowledge.ts`
10
11
 
12
+ ## Usage examples
13
+ - Default (auto-detect sources/destinations): `context-doc`
14
+ - Custom Codex source/destination: `context-doc --source /tmp/project/.codex --dest /tmp/project/.knowledge/.codex`
15
+ - Custom meta root (both Codex/Qwen resolution): `context-doc --meta-root /data/meta`
16
+ - Override project URL: `context-doc --project-url https://github.com/your/repo`
17
+ - Qwen source override: `context-doc --qwen-source /data/qwen/tmp/abcd1234`
18
+
11
19
  ## Flags
12
20
  - `--source, -s <path>` — explicit path to `.codex` (Codex source).
13
21
  - `--dest, -d <path>` — Codex destination root (defaults to `.knowledge/.codex`).
@@ -28,31 +28,27 @@ const readRepositoryUrl = (cwd, repositoryUrlOverride) => Effect.try({
28
28
  },
29
29
  catch: () => syncError("package.json", "Cannot read repository url"),
30
30
  });
31
- const resolveSourceDir = (cwd, override, metaRoot) => Effect.try({
32
- try: () => {
33
- const envSource = process.env.CODEX_SOURCE_DIR;
34
- const metaCandidate = metaRoot === undefined
35
- ? undefined
36
- : metaRoot.endsWith(".codex")
37
- ? metaRoot
38
- : path.join(metaRoot, ".codex");
39
- const localSource = path.join(cwd, ".codex");
40
- const homeSource = path.join(os.homedir(), ".codex");
41
- const candidates = [
42
- override,
43
- envSource,
44
- metaCandidate,
45
- localSource,
46
- homeSource,
47
- ];
48
- const existing = candidates.find((candidate) => candidate !== undefined && fs.existsSync(candidate));
49
- if (existing === undefined) {
50
- throw new Error("source .codex not found");
51
- }
52
- return existing;
53
- },
54
- catch: () => syncError(".codex", "Source .codex directory is missing"),
55
- });
31
+ const resolveSourceDir = (cwd, override, metaRoot) => pipe(Effect.sync(() => {
32
+ const envSource = process.env.CODEX_SOURCE_DIR;
33
+ const metaCandidate = metaRoot === undefined
34
+ ? undefined
35
+ : metaRoot.endsWith(".codex")
36
+ ? metaRoot
37
+ : path.join(metaRoot, ".codex");
38
+ const localSource = path.join(cwd, ".codex");
39
+ const homeSource = path.join(os.homedir(), ".codex");
40
+ const candidates = [
41
+ override,
42
+ envSource,
43
+ metaCandidate,
44
+ localSource,
45
+ homeSource,
46
+ ].filter((candidate) => candidate !== undefined);
47
+ const existing = candidates.find((candidate) => fs.existsSync(candidate));
48
+ return { existing, candidates };
49
+ }), Effect.flatMap(({ existing, candidates }) => existing === undefined
50
+ ? Effect.fail(syncError(".codex", `Source .codex directory is missing; checked: ${candidates.join(", ")}`))
51
+ : Effect.succeed(existing)));
56
52
  const collectJsonlFiles = (root) => Effect.try({
57
53
  try: () => {
58
54
  const collected = [];
@@ -115,5 +111,5 @@ export const syncCodex = (options) => Effect.gen(function* (_) {
115
111
  const allJsonlFiles = yield* _(collectJsonlFiles(sourceDir));
116
112
  const relevantFiles = yield* _(selectRelevantFiles(allJsonlFiles, locator));
117
113
  yield* _(Effect.forEach(relevantFiles, (filePath) => copyRelevantFile(sourceDir, destinationDir, filePath)));
118
- yield* _(Console.log(`Synced ${relevantFiles.length} dialog files into .knowledge/.codex`));
119
- });
114
+ yield* _(Console.log(`Synced ${relevantFiles.length} dialog files into .knowledge/.codex from ${sourceDir}`));
115
+ }).pipe(Effect.catchAll((error) => Console.log(`Codex source not found; skipped syncing Codex dialog files (${error.reason})`)));
@@ -26,7 +26,7 @@ const copyDirectoryJsonOnly = (sourceRoot, destinationRoot) => Effect.try({
26
26
  catch: () => syncError(sourceRoot, "Cannot traverse Qwen directory"),
27
27
  });
28
28
  const qwenHashFromPath = (projectPath) => createHash("sha256").update(projectPath).digest("hex");
29
- const resolveQwenSourceDir = (cwd, override, metaRoot) => pipe(Effect.sync(() => {
29
+ const resolveQwenSourceDir = (cwd, override, metaRoot) => Effect.gen(function* (_) {
30
30
  const hash = qwenHashFromPath(cwd);
31
31
  const envSource = process.env.QWEN_SOURCE_DIR;
32
32
  const baseFromMeta = metaRoot === undefined
@@ -41,9 +41,11 @@ const resolveQwenSourceDir = (cwd, override, metaRoot) => pipe(Effect.sync(() =>
41
41
  baseFromMeta ? path.join(baseFromMeta, "tmp", hash) : undefined,
42
42
  path.join(cwd, ".qwen", "tmp", hash),
43
43
  path.join(homeBase, "tmp", hash),
44
- ];
45
- return candidates.find((candidate) => candidate !== undefined && fs.existsSync(candidate));
46
- }), Effect.flatMap((found) => found === undefined
47
- ? Effect.fail(syncError(".qwen", "Qwen source directory is missing"))
48
- : Effect.succeed(found)));
49
- export const syncQwen = (options) => pipe(resolveQwenSourceDir(options.cwd, options.qwenSourceDir, options.metaRoot), Effect.flatMap((qwenSource) => pipe(ensureDirectory(path.join(options.cwd, ".knowledge", ".qwen")), Effect.flatMap(() => copyDirectoryJsonOnly(qwenSource, path.join(options.cwd, ".knowledge", ".qwen"))), Effect.flatMap((copiedCount) => Console.log(`Synced ${copiedCount} Qwen dialog files into .knowledge/.qwen`)))), Effect.catchAll(() => Console.log("Qwen source not found; skipped syncing Qwen dialog files")));
44
+ ].filter((candidate) => candidate !== undefined);
45
+ const found = candidates.find((candidate) => fs.existsSync(candidate));
46
+ if (found === undefined) {
47
+ return yield* _(Effect.fail(syncError(".qwen", `Qwen source directory is missing; checked: ${candidates.join(", ")}`)));
48
+ }
49
+ return found;
50
+ });
51
+ export const syncQwen = (options) => pipe(resolveQwenSourceDir(options.cwd, options.qwenSourceDir, options.metaRoot), Effect.tap((qwenSource) => Console.log(`Qwen source resolved: ${qwenSource}`)), Effect.flatMap((qwenSource) => pipe(ensureDirectory(path.join(options.cwd, ".knowledge", ".qwen")), Effect.flatMap(() => copyDirectoryJsonOnly(qwenSource, path.join(options.cwd, ".knowledge", ".qwen"))), Effect.flatMap((copiedCount) => Console.log(`Synced ${copiedCount} Qwen dialog files into .knowledge/.qwen`)))), Effect.catchAll((error) => Console.log(`Qwen source not found; skipped syncing Qwen dialog files (${error.reason})`)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prover-coder-ai/context-doc",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -12,7 +12,7 @@
12
12
  "release": "npm run build && npm run lint && npm version patch && npm publish --access public"
13
13
  },
14
14
  "bin": {
15
- "knowledge-sync": "dist/shell/syncKnowledge.js"
15
+ "context-doc": "dist/shell/syncKnowledge.js"
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",
@@ -46,8 +46,8 @@ const resolveSourceDir = (
46
46
  override?: string,
47
47
  metaRoot?: string,
48
48
  ): Effect.Effect<string, SyncError> =>
49
- Effect.try({
50
- try: () => {
49
+ pipe(
50
+ Effect.sync(() => {
51
51
  const envSource = process.env.CODEX_SOURCE_DIR;
52
52
  const metaCandidate =
53
53
  metaRoot === undefined
@@ -63,19 +63,23 @@ const resolveSourceDir = (
63
63
  metaCandidate,
64
64
  localSource,
65
65
  homeSource,
66
- ];
67
- const existing = candidates.find(
68
- (candidate) => candidate !== undefined && fs.existsSync(candidate),
69
- );
70
-
71
- if (existing === undefined) {
72
- throw new Error("source .codex not found");
73
- }
74
-
75
- return existing;
76
- },
77
- catch: () => syncError(".codex", "Source .codex directory is missing"),
78
- });
66
+ ].filter((candidate): candidate is string => candidate !== undefined);
67
+
68
+ const existing = candidates.find((candidate) => fs.existsSync(candidate));
69
+
70
+ return { existing, candidates };
71
+ }),
72
+ Effect.flatMap(({ existing, candidates }) =>
73
+ existing === undefined
74
+ ? Effect.fail(
75
+ syncError(
76
+ ".codex",
77
+ `Source .codex directory is missing; checked: ${candidates.join(", ")}`,
78
+ ),
79
+ )
80
+ : Effect.succeed(existing),
81
+ ),
82
+ );
79
83
 
80
84
  const collectJsonlFiles = (
81
85
  root: string,
@@ -183,7 +187,13 @@ export const syncCodex = (
183
187
 
184
188
  yield* _(
185
189
  Console.log(
186
- `Synced ${relevantFiles.length} dialog files into .knowledge/.codex`,
190
+ `Synced ${relevantFiles.length} dialog files into .knowledge/.codex from ${sourceDir}`,
187
191
  ),
188
192
  );
189
- });
193
+ }).pipe(
194
+ Effect.catchAll((error) =>
195
+ Console.log(
196
+ `Codex source not found; skipped syncing Codex dialog files (${error.reason})`,
197
+ ),
198
+ ),
199
+ );
@@ -40,42 +40,49 @@ const resolveQwenSourceDir = (
40
40
  override?: string,
41
41
  metaRoot?: string,
42
42
  ): Effect.Effect<string, SyncError> =>
43
- pipe(
44
- Effect.sync(() => {
45
- const hash = qwenHashFromPath(cwd);
46
- const envSource = process.env.QWEN_SOURCE_DIR;
47
- const baseFromMeta =
48
- metaRoot === undefined
49
- ? undefined
50
- : metaRoot.endsWith(".qwen")
51
- ? metaRoot
52
- : path.join(metaRoot, ".qwen");
53
- const homeBase = path.join(os.homedir(), ".qwen");
43
+ Effect.gen(function* (_) {
44
+ const hash = qwenHashFromPath(cwd);
45
+ const envSource = process.env.QWEN_SOURCE_DIR;
46
+ const baseFromMeta =
47
+ metaRoot === undefined
48
+ ? undefined
49
+ : metaRoot.endsWith(".qwen")
50
+ ? metaRoot
51
+ : path.join(metaRoot, ".qwen");
52
+ const homeBase = path.join(os.homedir(), ".qwen");
53
+
54
+ const candidates = [
55
+ override,
56
+ envSource,
57
+ baseFromMeta ? path.join(baseFromMeta, "tmp", hash) : undefined,
58
+ path.join(cwd, ".qwen", "tmp", hash),
59
+ path.join(homeBase, "tmp", hash),
60
+ ].filter((candidate): candidate is string => candidate !== undefined);
54
61
 
55
- const candidates = [
56
- override,
57
- envSource,
58
- baseFromMeta ? path.join(baseFromMeta, "tmp", hash) : undefined,
59
- path.join(cwd, ".qwen", "tmp", hash),
60
- path.join(homeBase, "tmp", hash),
61
- ];
62
+ const found = candidates.find((candidate) => fs.existsSync(candidate));
62
63
 
63
- return candidates.find(
64
- (candidate) => candidate !== undefined && fs.existsSync(candidate),
64
+ if (found === undefined) {
65
+ return yield* _(
66
+ Effect.fail(
67
+ syncError(
68
+ ".qwen",
69
+ `Qwen source directory is missing; checked: ${candidates.join(", ")}`,
70
+ ),
71
+ ),
65
72
  );
66
- }),
67
- Effect.flatMap((found) =>
68
- found === undefined
69
- ? Effect.fail(syncError(".qwen", "Qwen source directory is missing"))
70
- : Effect.succeed(found),
71
- ),
72
- );
73
+ }
74
+
75
+ return found;
76
+ });
73
77
 
74
78
  export const syncQwen = (
75
79
  options: SyncOptions,
76
80
  ): Effect.Effect<void, SyncError> =>
77
81
  pipe(
78
82
  resolveQwenSourceDir(options.cwd, options.qwenSourceDir, options.metaRoot),
83
+ Effect.tap((qwenSource) =>
84
+ Console.log(`Qwen source resolved: ${qwenSource}`),
85
+ ),
79
86
  Effect.flatMap((qwenSource) =>
80
87
  pipe(
81
88
  ensureDirectory(path.join(options.cwd, ".knowledge", ".qwen")),
@@ -92,7 +99,9 @@ export const syncQwen = (
92
99
  ),
93
100
  ),
94
101
  ),
95
- Effect.catchAll(() =>
96
- Console.log("Qwen source not found; skipped syncing Qwen dialog files"),
102
+ Effect.catchAll((error) =>
103
+ Console.log(
104
+ `Qwen source not found; skipped syncing Qwen dialog files (${error.reason})`,
105
+ ),
97
106
  ),
98
107
  );