@x1aoye/conflux-oc 0.1.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.
- package/LICENSE +21 -0
- package/README.md +73 -0
- package/dist/audit/archive-manager.d.ts +4 -0
- package/dist/audit/change-detector.d.ts +10 -0
- package/dist/audit/migration-map.d.ts +8 -0
- package/dist/config.d.ts +36 -0
- package/dist/detection/language.d.ts +2 -0
- package/dist/detection/machine-id.d.ts +6 -0
- package/dist/detection/platform.d.ts +6 -0
- package/dist/detection/project.d.ts +14 -0
- package/dist/detection/toolchain.d.ts +16 -0
- package/dist/hooks/file-edited.d.ts +3 -0
- package/dist/hooks/session-created.d.ts +3 -0
- package/dist/hooks/tool-execute-before.d.ts +3 -0
- package/dist/i18n/en.d.ts +2 -0
- package/dist/i18n/index.d.ts +1 -0
- package/dist/i18n/zh.d.ts +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1394 -0
- package/dist/layers/machine-layer.d.ts +20 -0
- package/dist/layers/platform-layer.d.ts +4 -0
- package/dist/layers/project-layer.d.ts +7 -0
- package/dist/layers/registry.d.ts +8 -0
- package/dist/layers/user-layer.d.ts +15 -0
- package/dist/security/sanitizer.d.ts +4 -0
- package/dist/storage/local.d.ts +9 -0
- package/dist/storage/types.d.ts +6 -0
- package/dist/tools/get-machine-context.d.ts +10 -0
- package/dist/tools/note-discovery.d.ts +23 -0
- package/dist/utils/knowledge-router.d.ts +13 -0
- package/dist/utils/parsers.d.ts +8 -0
- package/package.json +60 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ResolvedPluginConfig } from "../config.js";
|
|
2
|
+
export interface MachineDomain {
|
|
3
|
+
paths?: Record<string, string>;
|
|
4
|
+
versions?: Record<string, string>;
|
|
5
|
+
version?: string;
|
|
6
|
+
versions_list?: string[];
|
|
7
|
+
nvm_dir?: string;
|
|
8
|
+
gopath?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface MachineProfile {
|
|
11
|
+
machine_id: string;
|
|
12
|
+
id_method: "dmi" | "machine-id" | "hostname-mac";
|
|
13
|
+
hostname: string;
|
|
14
|
+
last_updated: string;
|
|
15
|
+
domains: Record<string, MachineDomain>;
|
|
16
|
+
}
|
|
17
|
+
export declare function machineProfilePath(config: ResolvedPluginConfig): string;
|
|
18
|
+
export declare function loadMachineProfile(config: ResolvedPluginConfig): MachineProfile | null;
|
|
19
|
+
export declare function saveMachineProfile(config: ResolvedPluginConfig, profile: MachineProfile): void;
|
|
20
|
+
export declare function createMachineProfile(config: ResolvedPluginConfig, domains: Record<string, MachineDomain>): MachineProfile;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type PlatformInfo } from "../detection/platform.js";
|
|
2
|
+
import type { ResolvedPluginConfig } from "../config.js";
|
|
3
|
+
export declare function getPlatformContext(_config: ResolvedPluginConfig): PlatformInfo;
|
|
4
|
+
export declare function formatPlatformContext(platform: PlatformInfo): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ResolvedPluginConfig } from "../config.js";
|
|
2
|
+
import { type ProjectRuntime } from "../detection/project.js";
|
|
3
|
+
export declare function getProjectRuntime(config: ResolvedPluginConfig): ProjectRuntime;
|
|
4
|
+
export declare function getRecordedRequirements(config: ResolvedPluginConfig): Record<string, import("../detection/project.js").RuntimeRequirement> | null;
|
|
5
|
+
export declare function diffRuntimeVersions(current: ProjectRuntime, recorded: Record<string, {
|
|
6
|
+
version: string;
|
|
7
|
+
}> | null): string[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LayerConfig } from "../config.js";
|
|
2
|
+
export declare class LayerRegistry {
|
|
3
|
+
private layers;
|
|
4
|
+
constructor(layers: LayerConfig[]);
|
|
5
|
+
getByPriority(): LayerConfig[];
|
|
6
|
+
getByName(name: string): LayerConfig | undefined;
|
|
7
|
+
add(layer: LayerConfig): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ResolvedPluginConfig } from "../config.js";
|
|
2
|
+
export interface UserPreferences {
|
|
3
|
+
user: string;
|
|
4
|
+
last_updated: string;
|
|
5
|
+
output_preferences: {
|
|
6
|
+
comment_style: string;
|
|
7
|
+
language: string;
|
|
8
|
+
verbosity: string;
|
|
9
|
+
};
|
|
10
|
+
security_boundaries: {
|
|
11
|
+
sudo: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function userProfilePath(config: ResolvedPluginConfig): string;
|
|
15
|
+
export declare function loadUserPreferences(config: ResolvedPluginConfig): UserPreferences;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function isSensitiveFilePath(filePath: string): boolean;
|
|
2
|
+
export declare function containsSensitiveContent(content: string): string[];
|
|
3
|
+
export declare function redactSensitive(content: string): string;
|
|
4
|
+
export declare function shouldBlockRead(filePath: string): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { StorageAdapter } from "./types.js";
|
|
2
|
+
export declare class LocalStorageAdapter implements StorageAdapter {
|
|
3
|
+
private basePath;
|
|
4
|
+
constructor(basePath: string);
|
|
5
|
+
read(path: string): string | null;
|
|
6
|
+
write(path: string, content: string): void;
|
|
7
|
+
list(dir: string): string[];
|
|
8
|
+
delete(path: string): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ResolvedPluginConfig } from "../config.js";
|
|
2
|
+
export declare function createGetMachineContextTool(config: ResolvedPluginConfig): {
|
|
3
|
+
description: string;
|
|
4
|
+
args: {
|
|
5
|
+
domain: import("zod").ZodString;
|
|
6
|
+
};
|
|
7
|
+
execute(args: {
|
|
8
|
+
domain: string;
|
|
9
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ResolvedPluginConfig } from "../config.js";
|
|
2
|
+
export declare function createNoteDiscoveryTool(config: ResolvedPluginConfig): {
|
|
3
|
+
description: string;
|
|
4
|
+
args: {
|
|
5
|
+
domain: import("zod").ZodString;
|
|
6
|
+
content: import("zod").ZodString;
|
|
7
|
+
layer: import("zod").ZodEnum<{
|
|
8
|
+
machine: "machine";
|
|
9
|
+
user: "user";
|
|
10
|
+
project: "project";
|
|
11
|
+
}>;
|
|
12
|
+
scope: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
13
|
+
branch: "branch";
|
|
14
|
+
cross: "cross";
|
|
15
|
+
}>>;
|
|
16
|
+
};
|
|
17
|
+
execute(args: {
|
|
18
|
+
domain: string;
|
|
19
|
+
content: string;
|
|
20
|
+
layer: "machine" | "user" | "project";
|
|
21
|
+
scope?: "branch" | "cross" | undefined;
|
|
22
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
|
|
23
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ResolvedPluginConfig } from "../config.js";
|
|
2
|
+
export type KnowledgeScope = "branch" | "cross";
|
|
3
|
+
export type KnowledgeLayer = "project" | "machine" | "platform" | "user";
|
|
4
|
+
export interface DiscoveryNote {
|
|
5
|
+
domain: string;
|
|
6
|
+
content: string;
|
|
7
|
+
layer: KnowledgeLayer;
|
|
8
|
+
scope?: KnowledgeScope;
|
|
9
|
+
}
|
|
10
|
+
export declare function determineScope(note: DiscoveryNote, config: ResolvedPluginConfig): KnowledgeScope;
|
|
11
|
+
export declare function resolvePath(note: DiscoveryNote, config: ResolvedPluginConfig): string;
|
|
12
|
+
export declare function isToolOutputSource(_source: string): boolean;
|
|
13
|
+
export declare function isUserAssumptionSource(_source: string): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ParsedContent {
|
|
2
|
+
raw: string;
|
|
3
|
+
parsed: Record<string, unknown> | null;
|
|
4
|
+
}
|
|
5
|
+
export type ParserFn = (content: string) => Record<string, unknown>;
|
|
6
|
+
export declare function registerParser(ext: string, parser: ParserFn): void;
|
|
7
|
+
export declare function readParsed(basePath: string, relPath: string): ParsedContent | null;
|
|
8
|
+
export declare function writeParsed(basePath: string, relPath: string, content: string): void;
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
+
"name": "@x1aoye/conflux-oc",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Auto-learning plugin for opencode — cross-session project/machine/user context memory",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"clean": "rm -rf dist",
|
|
17
|
+
"build": "npm run clean && tsup && tsc --emitDeclarationOnly",
|
|
18
|
+
"prepublishOnly": "npm run build",
|
|
19
|
+
"dev": "opencode plugin dev",
|
|
20
|
+
"typecheck": "tsc --noEmit"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"opencode",
|
|
24
|
+
"opencode-plugin",
|
|
25
|
+
"plugin",
|
|
26
|
+
"learning",
|
|
27
|
+
"context",
|
|
28
|
+
"memory",
|
|
29
|
+
"knowledge"
|
|
30
|
+
],
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/zoex1aoye/conflux-oc.git"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/zoex1aoye/conflux-oc/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/zoex1aoye/conflux-oc#readme",
|
|
39
|
+
"author": "zoex",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@opencode-ai/plugin": ">=1.4.3"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@opencode-ai/sdk": "^1.4.3",
|
|
46
|
+
"jsonc-parser": "^3.3.1",
|
|
47
|
+
"yaml": "^2.7.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@opencode-ai/plugin": "^1.4.3",
|
|
51
|
+
"@types/node": "^22.0.0",
|
|
52
|
+
"tsup": "^8.5.1",
|
|
53
|
+
"typescript": "^5.7.0"
|
|
54
|
+
},
|
|
55
|
+
"files": [
|
|
56
|
+
"dist/",
|
|
57
|
+
"README.md",
|
|
58
|
+
"LICENSE"
|
|
59
|
+
]
|
|
60
|
+
}
|