@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 x1aoye
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Conflux-OC
|
|
2
|
+
|
|
3
|
+
Auto-learning plugin for [opencode](https://opencode.ai) — cross-session project/machine/user context memory. From message 1, the model knows your OS, toolchain versions, project structure, and knowledge routing rules.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
opencode plugin @x1aoye/conflux-oc@latest --global
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or add to your `opencode.json`:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{ "plugin": ["@x1aoye/conflux-oc"] }
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## What It Does
|
|
18
|
+
|
|
19
|
+
### Session Context Injection (noReply)
|
|
20
|
+
On every new session, Conflux silently injects:
|
|
21
|
+
|
|
22
|
+
- **Platform**: OS, shell, CPU architecture
|
|
23
|
+
- **Machine**: Available dev toolchains (java/go/node/python) with versions and paths
|
|
24
|
+
- **Project**: Languages, runtime versions, build/test commands, git branch
|
|
25
|
+
- **User**: Output preferences (language, verbosity, comment style)
|
|
26
|
+
- **Knowledge Rules**: How to record and route discovered knowledge
|
|
27
|
+
|
|
28
|
+
### Version Switching
|
|
29
|
+
Automatically prepends `export JAVA_HOME=...` before build/run commands based on `runtime-requirements.yaml`.
|
|
30
|
+
|
|
31
|
+
### Knowledge Management
|
|
32
|
+
- **`note_discovery`** tool: Model records architecture decisions, branch progress, toolchain info
|
|
33
|
+
- **`get_machine_context`** tool: Query specific toolchain domain details
|
|
34
|
+
- **Knowledge routing**: Core architecture → `_shared/` (cross-branch); branch progress → `SKILL.md`
|
|
35
|
+
- **Decision logging**: Automatically creates timestamped decision logs on substantive SKILL.md changes
|
|
36
|
+
- **Archive management**: Old skill variants preserved in `_archive/`
|
|
37
|
+
|
|
38
|
+
### Migration Tracking
|
|
39
|
+
- Scans `Migration Map` sections in skill files
|
|
40
|
+
- Injects migration hints into session context
|
|
41
|
+
- Alerts when editing files with known migration paths
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
Conflux searches for config in this order (each level overrides the previous):
|
|
46
|
+
|
|
47
|
+
1. **Project**: `.opencode/conflux-oc.jsonc`
|
|
48
|
+
2. **Custom**: `$OPENCODE_CONFIG_DIR/conflux-oc.jsonc`
|
|
49
|
+
3. **Global**: `~/.config/opencode/conflux-oc.jsonc`
|
|
50
|
+
4. **Built-in defaults** (always available as fallback)
|
|
51
|
+
|
|
52
|
+
```jsonc
|
|
53
|
+
// .opencode/conflux-oc.jsonc
|
|
54
|
+
{
|
|
55
|
+
"layers": [
|
|
56
|
+
{ "name": "platform", "priority": 0, "storage": "transform-only", "inject": "always" },
|
|
57
|
+
{ "name": "machine", "priority": 1, "storage": { "type": "local", "path": "machines/{id}.json" }, "inject": "summary-only" },
|
|
58
|
+
{ "name": "user", "priority": 2, "storage": { "type": "local", "path": "users/{name}.json" }, "inject": "always" },
|
|
59
|
+
{ "name": "project", "priority": 3, "storage": { "type": "local", "path": ".opencode/skills/" }, "inject": "on-demand" }
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Privacy
|
|
65
|
+
|
|
66
|
+
- Machine and User profiles stored in `~/.config/opencode/plugins/conflux-oc/` (never in git)
|
|
67
|
+
- Blocks read access to `.env`, `.ssh/`, `.gnupg/`, and sensitive files
|
|
68
|
+
- Filters sensitive content (private keys, tokens, secrets) from knowledge recording
|
|
69
|
+
- Project skills stored in `.opencode/skills/` (in git, team-shareable)
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ChangeInfo } from "./change-detector.js";
|
|
2
|
+
export declare function createDecisionLog(filePath: string, change: ChangeInfo): string | null;
|
|
3
|
+
export declare function archiveOldVariant(filePath: string, change: ChangeInfo): string | null;
|
|
4
|
+
export declare function updateMigrationMap(filePath: string, oldName: string, newName: string): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ChangeInfo {
|
|
2
|
+
isSubstantial: boolean;
|
|
3
|
+
oldName: string | null;
|
|
4
|
+
newName: string | null;
|
|
5
|
+
oldHeadings: string[];
|
|
6
|
+
newHeadings: string[];
|
|
7
|
+
linesAdded: number;
|
|
8
|
+
linesRemoved: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function analyzeChange(oldContent: string | null, newContent: string, filePath: string): ChangeInfo;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface MigrationEntry {
|
|
2
|
+
oldPath: string;
|
|
3
|
+
newApi: string;
|
|
4
|
+
sourceFile: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function parseAllMigrationMaps(skillsDir: string): MigrationEntry[];
|
|
7
|
+
export declare function findMigrationMatch(filePath: string, entries: MigrationEntry[]): MigrationEntry | null;
|
|
8
|
+
export declare function formatMigrationHints(entries: MigrationEntry[]): string;
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface LayerConfig {
|
|
2
|
+
name: string;
|
|
3
|
+
priority: number;
|
|
4
|
+
storage: string | {
|
|
5
|
+
type: string;
|
|
6
|
+
path: string;
|
|
7
|
+
};
|
|
8
|
+
inject: "always" | "summary-only" | "on-demand";
|
|
9
|
+
}
|
|
10
|
+
export interface BehaviorRule {
|
|
11
|
+
id: string;
|
|
12
|
+
trigger: string;
|
|
13
|
+
rule: string;
|
|
14
|
+
condition?: string;
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface PluginConfig {
|
|
18
|
+
layers: LayerConfig[];
|
|
19
|
+
behavior_rules: BehaviorRule[];
|
|
20
|
+
}
|
|
21
|
+
export interface ResolvedStorage {
|
|
22
|
+
type: "none" | "local";
|
|
23
|
+
basePath: string;
|
|
24
|
+
template: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ResolvedPluginConfig {
|
|
27
|
+
layers: LayerConfig[];
|
|
28
|
+
behavior_rules: BehaviorRule[];
|
|
29
|
+
pluginDataDir: string;
|
|
30
|
+
projectRoot: string;
|
|
31
|
+
resolvedStorages: Record<string, ResolvedStorage>;
|
|
32
|
+
}
|
|
33
|
+
export declare function resolvePluginDataDir(): string;
|
|
34
|
+
export declare function loadPluginConfig(projectRoot?: string): PluginConfig;
|
|
35
|
+
export declare function resolvePluginConfig(projectRoot?: string): ResolvedPluginConfig;
|
|
36
|
+
export declare function getEnabledRules(config: PluginConfig): BehaviorRule[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface RuntimeRequirement {
|
|
2
|
+
version: string;
|
|
3
|
+
source?: string;
|
|
4
|
+
switching?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ProjectRuntime {
|
|
7
|
+
languages: string[];
|
|
8
|
+
versions: Record<string, string>;
|
|
9
|
+
build: string;
|
|
10
|
+
test: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function runtimeRequirementsPath(projectRoot: string): string;
|
|
13
|
+
export declare function readRuntimeRequirements(projectRoot: string): Record<string, RuntimeRequirement> | null;
|
|
14
|
+
export declare function detectProjectRuntime(projectRoot: string): ProjectRuntime;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ToolchainEntry {
|
|
2
|
+
path: string;
|
|
3
|
+
version: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ToolchainDomain {
|
|
6
|
+
paths: Record<string, string>;
|
|
7
|
+
versions: Record<string, string>;
|
|
8
|
+
extras?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export interface ToolchainResult {
|
|
11
|
+
java: ToolchainDomain | null;
|
|
12
|
+
go: ToolchainDomain | null;
|
|
13
|
+
node: ToolchainDomain | null;
|
|
14
|
+
python: ToolchainDomain | null;
|
|
15
|
+
}
|
|
16
|
+
export declare function detectToolchain(): Promise<ToolchainResult>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ResolvedPluginConfig } from "../config.js";
|
|
2
|
+
import type { LayerRegistry } from "../layers/registry.js";
|
|
3
|
+
export declare function createSessionCreatedHandler(client: any, config: ResolvedPluginConfig, _registry: LayerRegistry): (input: any, _output: any) => Promise<void>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ResolvedPluginConfig } from "../config.js";
|
|
2
|
+
import type { LayerRegistry } from "../layers/registry.js";
|
|
3
|
+
export declare function createToolExecuteBeforeHandler(config: ResolvedPluginConfig, _registry: LayerRegistry): (input: any, output: any) => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function t(key: string, params?: Record<string, string | number>): string;
|
package/dist/index.d.ts
ADDED