@prover-coder-ai/context-doc 1.0.12 → 1.0.13
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/.jscpd.json +16 -0
- package/CHANGELOG.md +13 -0
- package/bin/context-doc.js +12 -0
- package/biome.json +37 -0
- package/eslint.config.mts +305 -0
- package/eslint.effect-ts-check.config.mjs +220 -0
- package/linter.config.json +33 -0
- package/package.json +72 -41
- package/src/app/main.ts +29 -0
- package/src/app/program.ts +32 -0
- package/src/core/knowledge.ts +93 -117
- package/src/shell/cli.ts +73 -5
- package/src/shell/services/crypto.ts +50 -0
- package/src/shell/services/file-system.ts +142 -0
- package/src/shell/services/runtime-env.ts +54 -0
- package/src/shell/sync/index.ts +35 -0
- package/src/shell/sync/shared.ts +229 -0
- package/src/shell/sync/sources/claude.ts +54 -0
- package/src/shell/sync/sources/codex.ts +261 -0
- package/src/shell/sync/sources/qwen.ts +97 -0
- package/src/shell/sync/types.ts +47 -0
- package/tests/core/knowledge.test.ts +95 -0
- package/tests/shell/cli-pack.test.ts +176 -0
- package/tests/shell/sync-knowledge.test.ts +203 -0
- package/tests/support/fs-helpers.ts +50 -0
- package/tsconfig.json +19 -0
- package/vite.config.ts +32 -0
- package/vitest.config.ts +70 -66
- package/README.md +0 -42
- package/dist/core/greeting.js +0 -25
- package/dist/core/knowledge.js +0 -49
- package/dist/main.js +0 -27
- package/dist/shell/claudeSync.js +0 -23
- package/dist/shell/cli.js +0 -5
- package/dist/shell/codexSync.js +0 -129
- package/dist/shell/qwenSync.js +0 -41
- package/dist/shell/syncKnowledge.js +0 -39
- package/dist/shell/syncShared.js +0 -49
- package/dist/shell/syncTypes.js +0 -1
- package/src/core/greeting.ts +0 -39
- package/src/main.ts +0 -49
- package/src/shell/claudeSync.ts +0 -55
- package/src/shell/codexSync.ts +0 -236
- package/src/shell/qwenSync.ts +0 -73
- package/src/shell/syncKnowledge.ts +0 -49
- package/src/shell/syncShared.ts +0 -94
- package/src/shell/syncTypes.ts +0 -30
- package/src/types/env.d.ts +0 -10
- package/tsconfig.build.json +0 -18
package/src/shell/qwenSync.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import os from "node:os";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { Effect } from "effect";
|
|
6
|
-
import { copyFilteredFiles, runSyncSource, syncError } from "./syncShared.js";
|
|
7
|
-
import type { SyncError, SyncOptions, SyncSource } from "./syncTypes.js";
|
|
8
|
-
|
|
9
|
-
const qwenHashFromPath = (projectPath: string): string =>
|
|
10
|
-
createHash("sha256").update(projectPath).digest("hex");
|
|
11
|
-
|
|
12
|
-
const resolveQwenSourceDir = (
|
|
13
|
-
cwd: string,
|
|
14
|
-
override?: string,
|
|
15
|
-
metaRoot?: string,
|
|
16
|
-
): Effect.Effect<string, SyncError> =>
|
|
17
|
-
Effect.gen(function* (_) {
|
|
18
|
-
const hash = qwenHashFromPath(cwd);
|
|
19
|
-
const envSource = process.env.QWEN_SOURCE_DIR;
|
|
20
|
-
const baseFromMeta =
|
|
21
|
-
metaRoot === undefined
|
|
22
|
-
? undefined
|
|
23
|
-
: metaRoot.endsWith(".qwen")
|
|
24
|
-
? metaRoot
|
|
25
|
-
: path.join(metaRoot, ".qwen");
|
|
26
|
-
const metaKnowledge = path.join(metaRoot ?? "", ".knowledge", ".qwen");
|
|
27
|
-
const homeBase = path.join(os.homedir(), ".qwen");
|
|
28
|
-
const homeKnowledge = path.join(os.homedir(), ".knowledge", ".qwen");
|
|
29
|
-
|
|
30
|
-
const candidates = [
|
|
31
|
-
override,
|
|
32
|
-
envSource,
|
|
33
|
-
baseFromMeta ? path.join(baseFromMeta, "tmp", hash) : undefined,
|
|
34
|
-
path.join(cwd, ".qwen", "tmp", hash),
|
|
35
|
-
path.join(cwd, ".knowledge", ".qwen", "tmp", hash),
|
|
36
|
-
metaKnowledge ? path.join(metaKnowledge, "tmp", hash) : undefined,
|
|
37
|
-
path.join(homeBase, "tmp", hash),
|
|
38
|
-
path.join(homeKnowledge, "tmp", hash),
|
|
39
|
-
].filter((candidate): candidate is string => candidate !== undefined);
|
|
40
|
-
|
|
41
|
-
const found = candidates.find((candidate) => fs.existsSync(candidate));
|
|
42
|
-
|
|
43
|
-
if (found === undefined) {
|
|
44
|
-
return yield* _(
|
|
45
|
-
Effect.fail(
|
|
46
|
-
syncError(
|
|
47
|
-
".qwen",
|
|
48
|
-
`Qwen source directory is missing for hash ${hash}`,
|
|
49
|
-
),
|
|
50
|
-
),
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return found;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
export const syncQwen = (
|
|
58
|
-
options: SyncOptions,
|
|
59
|
-
): Effect.Effect<void, SyncError> => runSyncSource(qwenSource, options);
|
|
60
|
-
|
|
61
|
-
const qwenSource: SyncSource = {
|
|
62
|
-
name: "Qwen",
|
|
63
|
-
destSubdir: ".qwen",
|
|
64
|
-
resolveSource: (options) =>
|
|
65
|
-
resolveQwenSourceDir(options.cwd, options.qwenSourceDir, options.metaRoot),
|
|
66
|
-
copy: (sourceDir, destinationDir) =>
|
|
67
|
-
copyFilteredFiles(
|
|
68
|
-
sourceDir,
|
|
69
|
-
destinationDir,
|
|
70
|
-
(entry, fullPath) => entry.isFile() && fullPath.endsWith(".json"),
|
|
71
|
-
"Cannot traverse Qwen directory",
|
|
72
|
-
),
|
|
73
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Effect } from "effect";
|
|
3
|
-
import { syncClaude } from "./claudeSync.js";
|
|
4
|
-
import { syncCodex } from "./codexSync.js";
|
|
5
|
-
import { syncQwen } from "./qwenSync.js";
|
|
6
|
-
import type { SyncError, SyncOptions } from "./syncTypes.js";
|
|
7
|
-
|
|
8
|
-
// PURPOSE: Sync project-scoped dialogs (Codex + Qwen) into .knowledge storage.
|
|
9
|
-
export const buildSyncProgram = (
|
|
10
|
-
options: SyncOptions,
|
|
11
|
-
): Effect.Effect<void, SyncError> =>
|
|
12
|
-
Effect.gen(function* (_) {
|
|
13
|
-
yield* _(syncClaude(options));
|
|
14
|
-
yield* _(syncCodex(options));
|
|
15
|
-
yield* _(syncQwen(options));
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export const parseArgs = (): SyncOptions => {
|
|
19
|
-
const argv = process.argv.slice(2);
|
|
20
|
-
let result: SyncOptions = { cwd: process.cwd() };
|
|
21
|
-
|
|
22
|
-
const mapping: Readonly<Record<string, keyof SyncOptions>> = {
|
|
23
|
-
"--source": "sourceDir",
|
|
24
|
-
"-s": "sourceDir",
|
|
25
|
-
"--dest": "destinationDir",
|
|
26
|
-
"-d": "destinationDir",
|
|
27
|
-
"--project-url": "repositoryUrlOverride",
|
|
28
|
-
"--project-name": "repositoryUrlOverride",
|
|
29
|
-
"--meta-root": "metaRoot",
|
|
30
|
-
"--qwen-source": "qwenSourceDir",
|
|
31
|
-
"--claude-projects": "claudeProjectsRoot",
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
for (let i = 0; i < argv.length; i++) {
|
|
35
|
-
const arg = argv[i];
|
|
36
|
-
const key = mapping[arg as keyof typeof mapping];
|
|
37
|
-
if (key === undefined) {
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const value = argv[i + 1];
|
|
42
|
-
if (value !== undefined) {
|
|
43
|
-
result = { ...result, [key]: value };
|
|
44
|
-
i++;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return result;
|
|
49
|
-
};
|
package/src/shell/syncShared.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { Console, Effect } from "effect";
|
|
4
|
-
import { pipe } from "effect/Function";
|
|
5
|
-
import type { SyncError, SyncOptions, SyncSource } from "./syncTypes.js";
|
|
6
|
-
|
|
7
|
-
export const syncError = (pathValue: string, reason: string): SyncError => ({
|
|
8
|
-
_tag: "SyncError",
|
|
9
|
-
path: pathValue,
|
|
10
|
-
reason,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export const ensureDirectory = (
|
|
14
|
-
directory: string,
|
|
15
|
-
): Effect.Effect<void, SyncError> =>
|
|
16
|
-
Effect.try({
|
|
17
|
-
try: () => {
|
|
18
|
-
fs.mkdirSync(directory, { recursive: true });
|
|
19
|
-
},
|
|
20
|
-
catch: () =>
|
|
21
|
-
syncError(directory, "Cannot create destination directory structure"),
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export const runSyncSource = (
|
|
25
|
-
source: SyncSource,
|
|
26
|
-
options: SyncOptions,
|
|
27
|
-
): Effect.Effect<void, SyncError> =>
|
|
28
|
-
pipe(
|
|
29
|
-
Effect.gen(function* (_) {
|
|
30
|
-
const resolvedSource = yield* _(source.resolveSource(options));
|
|
31
|
-
const destination = path.join(
|
|
32
|
-
options.cwd,
|
|
33
|
-
".knowledge",
|
|
34
|
-
source.destSubdir,
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
if (path.resolve(resolvedSource) === path.resolve(destination)) {
|
|
38
|
-
yield* _(
|
|
39
|
-
Console.log(
|
|
40
|
-
`${source.name}: source equals destination; skipping copy to avoid duplicates`,
|
|
41
|
-
),
|
|
42
|
-
);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
yield* _(ensureDirectory(destination));
|
|
47
|
-
const copied = yield* _(
|
|
48
|
-
source.copy(resolvedSource, destination, options),
|
|
49
|
-
);
|
|
50
|
-
yield* _(
|
|
51
|
-
Console.log(
|
|
52
|
-
`${source.name}: copied ${copied} files from ${resolvedSource} to ${destination}`,
|
|
53
|
-
),
|
|
54
|
-
);
|
|
55
|
-
}),
|
|
56
|
-
Effect.catchAll((error: SyncError) =>
|
|
57
|
-
Console.log(
|
|
58
|
-
`${source.name}: source not found; skipped syncing (${error.reason})`,
|
|
59
|
-
),
|
|
60
|
-
),
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
export const copyFilteredFiles = (
|
|
64
|
-
sourceRoot: string,
|
|
65
|
-
destinationRoot: string,
|
|
66
|
-
isRelevant: (entry: fs.Dirent, fullPath: string) => boolean,
|
|
67
|
-
errorReason: string,
|
|
68
|
-
): Effect.Effect<number, SyncError> =>
|
|
69
|
-
Effect.try({
|
|
70
|
-
try: () => {
|
|
71
|
-
let copied = 0;
|
|
72
|
-
const walk = (current: string): void => {
|
|
73
|
-
const entries = fs.readdirSync(current, { withFileTypes: true });
|
|
74
|
-
for (const entry of entries) {
|
|
75
|
-
const full = path.join(current, entry.name);
|
|
76
|
-
if (entry.isDirectory()) {
|
|
77
|
-
walk(full);
|
|
78
|
-
} else if (isRelevant(entry, full)) {
|
|
79
|
-
const target = path.join(
|
|
80
|
-
destinationRoot,
|
|
81
|
-
path.relative(sourceRoot, full),
|
|
82
|
-
);
|
|
83
|
-
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
84
|
-
fs.copyFileSync(full, target);
|
|
85
|
-
copied += 1;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
walk(sourceRoot);
|
|
91
|
-
return copied;
|
|
92
|
-
},
|
|
93
|
-
catch: () => syncError(sourceRoot, errorReason),
|
|
94
|
-
});
|
package/src/shell/syncTypes.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type * as Fx from "effect";
|
|
2
|
-
|
|
3
|
-
export interface SyncError {
|
|
4
|
-
readonly _tag: "SyncError";
|
|
5
|
-
readonly path: string;
|
|
6
|
-
readonly reason: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface SyncOptions {
|
|
10
|
-
readonly cwd: string;
|
|
11
|
-
readonly sourceDir?: string;
|
|
12
|
-
readonly destinationDir?: string;
|
|
13
|
-
readonly repositoryUrlOverride?: string;
|
|
14
|
-
readonly metaRoot?: string;
|
|
15
|
-
readonly qwenSourceDir?: string;
|
|
16
|
-
readonly claudeProjectsRoot?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type SyncEffect<A> = Fx.Effect.Effect<A, SyncError>;
|
|
20
|
-
|
|
21
|
-
export interface SyncSource {
|
|
22
|
-
readonly name: string;
|
|
23
|
-
readonly destSubdir: ".codex" | ".qwen" | ".claude";
|
|
24
|
-
readonly resolveSource: (options: SyncOptions) => SyncEffect<string>;
|
|
25
|
-
readonly copy: (
|
|
26
|
-
sourceDir: string,
|
|
27
|
-
destinationDir: string,
|
|
28
|
-
options: SyncOptions,
|
|
29
|
-
) => SyncEffect<number>;
|
|
30
|
-
}
|
package/src/types/env.d.ts
DELETED
package/tsconfig.build.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// CHANGE: Emit compiled artifacts into dist instead of source tree
|
|
3
|
-
// WHY: Keep repository free of generated .js while still supporting production builds
|
|
4
|
-
// QUOTE(ТЗ): "FUNCTIONAL CORE, IMPERATIVE SHELL" — сборка отделена от исходников
|
|
5
|
-
// PURITY: SHELL (build configuration)
|
|
6
|
-
"extends": "./tsconfig.json",
|
|
7
|
-
"compilerOptions": {
|
|
8
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
9
|
-
// EMIT OVERRIDES (build-only)
|
|
10
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
11
|
-
"noEmit": false,
|
|
12
|
-
"outDir": "dist",
|
|
13
|
-
"rootDir": "src",
|
|
14
|
-
"tsBuildInfoFile": "dist/.tsbuildinfo"
|
|
15
|
-
},
|
|
16
|
-
"include": ["src/**/*"],
|
|
17
|
-
"exclude": ["tests/**/*", "node_modules", "dist"]
|
|
18
|
-
}
|