@osovv/vv-opencode 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/AGENTS.md +164 -0
- package/README.md +43 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +23 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/doctor.d.ts +19 -0
- package/dist/commands/doctor.js +70 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/guardian.d.ts +2 -0
- package/dist/commands/guardian.js +119 -0
- package/dist/commands/guardian.js.map +1 -0
- package/dist/commands/install.d.ts +28 -0
- package/dist/commands/install.js +59 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/status.d.ts +13 -0
- package/dist/commands/status.js +47 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/sync.d.ts +23 -0
- package/dist/commands/sync.js +49 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/opencode.d.ts +86 -0
- package/dist/lib/opencode.js +415 -0
- package/dist/lib/opencode.js.map +1 -0
- package/dist/lib/opencode.test.d.ts +1 -0
- package/dist/lib/opencode.test.js +47 -0
- package/dist/lib/opencode.test.js.map +1 -0
- package/dist/plugins/guardian.d.ts +2 -0
- package/dist/plugins/guardian.js +1135 -0
- package/dist/plugins/guardian.js.map +1 -0
- package/docs/development-plan.xml +155 -0
- package/docs/knowledge-graph.xml +42 -0
- package/docs/operational-packets.xml +106 -0
- package/docs/requirements.xml +66 -0
- package/docs/technology.xml +51 -0
- package/docs/verification-plan.xml +145 -0
- package/package.json +58 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# GRACE Framework - Project Engineering Protocol
|
|
2
|
+
|
|
3
|
+
## Keywords
|
|
4
|
+
opencode, plugins, workflow
|
|
5
|
+
|
|
6
|
+
## Annotation
|
|
7
|
+
Portable OpenCode workflow package with plugins and a Bun CLI for install, sync, and cross-device setup.
|
|
8
|
+
|
|
9
|
+
## Core Principles
|
|
10
|
+
|
|
11
|
+
### 1. Never Write Code Without a Contract
|
|
12
|
+
Before generating or editing any module, create or update its MODULE_CONTRACT with PURPOSE, SCOPE, INPUTS, and OUTPUTS. The contract is the source of truth. Code implements the contract, not the other way around.
|
|
13
|
+
|
|
14
|
+
### 2. Semantic Markup Is Load-Bearing Structure
|
|
15
|
+
Markers like `// START_BLOCK_<NAME>` and `// END_BLOCK_<NAME>` are navigation anchors, not documentation. They must be:
|
|
16
|
+
- uniquely named
|
|
17
|
+
- paired
|
|
18
|
+
- proportionally sized so one block fits inside an LLM working window
|
|
19
|
+
|
|
20
|
+
### 3. Knowledge Graph Is Always Current
|
|
21
|
+
`docs/knowledge-graph.xml` is the project map. When you add a module, move a module, rename exports, or add dependencies, update the graph so future agents can navigate deterministically.
|
|
22
|
+
|
|
23
|
+
### 4. Verification Is a First-Class Artifact
|
|
24
|
+
Testing, traces, and log anchors are designed before large execution waves. `docs/verification-plan.xml` is part of the architecture, not an afterthought. Logs are evidence. Tests are executable contracts.
|
|
25
|
+
|
|
26
|
+
### 5. Top-Down Synthesis
|
|
27
|
+
Code generation follows:
|
|
28
|
+
`RequirementsAnalysis -> TechnologyStack -> DevelopmentPlan -> VerificationPlan -> Code + Tests`
|
|
29
|
+
|
|
30
|
+
Never jump straight to code when requirements, architecture, or verification intent are still unclear.
|
|
31
|
+
|
|
32
|
+
### 6. Governed Autonomy
|
|
33
|
+
Agents have freedom in HOW to implement, but not in WHAT to build. Contracts, plans, graph references, and verification requirements define the allowed space.
|
|
34
|
+
|
|
35
|
+
## Semantic Markup Reference
|
|
36
|
+
|
|
37
|
+
### Module Level
|
|
38
|
+
```
|
|
39
|
+
// FILE: path/to/file.ext
|
|
40
|
+
// VERSION: 1.0.0
|
|
41
|
+
// START_MODULE_CONTRACT
|
|
42
|
+
// PURPOSE: [What this module does - one sentence]
|
|
43
|
+
// SCOPE: [What operations are included]
|
|
44
|
+
// DEPENDS: [List of module dependencies]
|
|
45
|
+
// LINKS: [Knowledge graph references]
|
|
46
|
+
// ROLE: [Optional: RUNTIME | TEST | BARREL | CONFIG | TYPES | SCRIPT]
|
|
47
|
+
// MAP_MODE: [Optional: EXPORTS | LOCALS | SUMMARY | NONE]
|
|
48
|
+
// END_MODULE_CONTRACT
|
|
49
|
+
//
|
|
50
|
+
// START_MODULE_MAP
|
|
51
|
+
// exportedSymbol - one-line description
|
|
52
|
+
// END_MODULE_MAP
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Function or Component Level
|
|
56
|
+
```
|
|
57
|
+
// START_CONTRACT: functionName
|
|
58
|
+
// PURPOSE: [What it does]
|
|
59
|
+
// INPUTS: { paramName: Type - description }
|
|
60
|
+
// OUTPUTS: { ReturnType - description }
|
|
61
|
+
// SIDE_EFFECTS: [External state changes or "none"]
|
|
62
|
+
// LINKS: [Related modules/functions]
|
|
63
|
+
// END_CONTRACT: functionName
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Code Block Level
|
|
67
|
+
```
|
|
68
|
+
// START_BLOCK_VALIDATE_INPUT
|
|
69
|
+
// ... code ...
|
|
70
|
+
// END_BLOCK_VALIDATE_INPUT
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Change Tracking
|
|
74
|
+
```
|
|
75
|
+
// START_CHANGE_SUMMARY
|
|
76
|
+
// LAST_CHANGE: [v1.2.0 - What changed and why]
|
|
77
|
+
// END_CHANGE_SUMMARY
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Optional Lint Semantics
|
|
81
|
+
|
|
82
|
+
Use `ROLE` and `MAP_MODE` only when the file should be linted differently from a normal runtime module.
|
|
83
|
+
|
|
84
|
+
- `RUNTIME` + `EXPORTS`: normal source files with public APIs
|
|
85
|
+
- `TEST` + `LOCALS`: tests where the map should describe helpers, fixtures, and assertion surfaces
|
|
86
|
+
- `BARREL` + `SUMMARY`: re-export aggregators and grouped entry points
|
|
87
|
+
- `CONFIG` + `NONE`: build or tool configuration files
|
|
88
|
+
- `TYPES` + `EXPORTS`: pure type/interface modules
|
|
89
|
+
- `SCRIPT` + `LOCALS`: CLI/bootstrap/smoke scripts
|
|
90
|
+
|
|
91
|
+
## Logging and Trace Convention
|
|
92
|
+
|
|
93
|
+
All important logs must point back to semantic blocks:
|
|
94
|
+
```
|
|
95
|
+
logger.info(`[ModuleName][functionName][BLOCK_NAME] message`, {
|
|
96
|
+
correlationId,
|
|
97
|
+
stableField: value,
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Rules:
|
|
102
|
+
- prefer structured fields over prose-heavy log lines
|
|
103
|
+
- redact secrets and high-risk payloads
|
|
104
|
+
- treat missing log anchors on critical branches as a verification defect
|
|
105
|
+
- update tests when log markers change intentionally
|
|
106
|
+
|
|
107
|
+
## Verification Conventions
|
|
108
|
+
|
|
109
|
+
`docs/verification-plan.xml` is the project-wide verification contract. Keep it current when module scope, test files, commands, critical log markers, or gate expectations change. Use `docs/operational-packets.xml` as the canonical schema for execution packets, graph deltas, verification deltas, and failure handoff packets.
|
|
110
|
+
|
|
111
|
+
Testing rules:
|
|
112
|
+
- deterministic assertions first
|
|
113
|
+
- trace or log assertions when trajectory matters
|
|
114
|
+
- test files may also carry MODULE_CONTRACT, MODULE_MAP, semantic blocks, and CHANGE_SUMMARY when they are substantial
|
|
115
|
+
- module-local tests should stay close to the module they verify
|
|
116
|
+
- wave-level and phase-level checks should be explicit in the verification plan
|
|
117
|
+
|
|
118
|
+
## File Structure
|
|
119
|
+
```
|
|
120
|
+
docs/
|
|
121
|
+
requirements.xml - Product requirements and use cases
|
|
122
|
+
technology.xml - Stack decisions, tooling, observability, testing
|
|
123
|
+
development-plan.xml - Modules, phases, data flows, ownership, write scopes
|
|
124
|
+
verification-plan.xml - Test strategy, trace expectations, module and phase gates
|
|
125
|
+
knowledge-graph.xml - Project-wide navigation graph
|
|
126
|
+
operational-packets.xml - Canonical packet, delta, and failure handoff templates
|
|
127
|
+
src/
|
|
128
|
+
... code with GRACE markup ...
|
|
129
|
+
tests/
|
|
130
|
+
... tests with GRACE-aware evidence where appropriate ...
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Documentation Artifacts - Unique Tag Convention
|
|
134
|
+
|
|
135
|
+
In `docs/*.xml`, repeated entities must use their unique ID as the XML tag name instead of a generic tag with an `ID` attribute. This reduces closing-tag ambiguity and gives LLMs stronger anchors.
|
|
136
|
+
|
|
137
|
+
### Tag naming conventions
|
|
138
|
+
|
|
139
|
+
| Entity type | Anti-pattern | Correct (unique tags) |
|
|
140
|
+
|---|---|---|
|
|
141
|
+
| Module | `<Module ID="M-CONFIG">...</Module>` | `<M-CONFIG NAME="Config" TYPE="UTILITY">...</M-CONFIG>` |
|
|
142
|
+
| Verification module | `<Verification ID="V-M-AUTH">...</Verification>` | `<V-M-AUTH MODULE="M-AUTH">...</V-M-AUTH>` |
|
|
143
|
+
| Phase | `<Phase number="1">...</Phase>` | `<Phase-1 name="Foundation">...</Phase-1>` |
|
|
144
|
+
| Flow | `<Flow ID="DF-SEARCH">...</Flow>` | `<DF-SEARCH NAME="...">...</DF-SEARCH>` |
|
|
145
|
+
| Use case | `<UseCase ID="UC-001">...</UseCase>` | `<UC-001>...</UC-001>` |
|
|
146
|
+
| Step | `<step order="1">...</step>` | `<step-1>...</step-1>` |
|
|
147
|
+
| Export | `<export name="config" .../>` | `<export-config .../>` |
|
|
148
|
+
| Function | `<function name="search" .../>` | `<fn-search .../>` |
|
|
149
|
+
| Type | `<type name="SearchResult" .../>` | `<type-SearchResult .../>` |
|
|
150
|
+
| Class | `<class name="Error" .../>` | `<class-Error .../>` |
|
|
151
|
+
|
|
152
|
+
### What NOT to change
|
|
153
|
+
- `CrossLink` tags stay self-closing
|
|
154
|
+
- single-use structural wrappers like `<contract>`, `<inputs>`, `<outputs>`, `<annotations>`, `<test-files>`, `<module-checks>`, and `<phase-gates>` stay generic
|
|
155
|
+
- code-level markup already uses unique names and stays as-is
|
|
156
|
+
|
|
157
|
+
## Rules for Modifications
|
|
158
|
+
|
|
159
|
+
1. Read the MODULE_CONTRACT before editing any file.
|
|
160
|
+
2. After editing source or test files, update MODULE_MAP in a way that matches the file's role and map mode.
|
|
161
|
+
3. After adding or removing modules, update `docs/knowledge-graph.xml`.
|
|
162
|
+
4. After changing test files, commands, critical scenarios, or log markers, update `docs/verification-plan.xml`.
|
|
163
|
+
5. After fixing bugs, add a CHANGE_SUMMARY entry and strengthen nearby verification if the old evidence was weak.
|
|
164
|
+
6. Never remove semantic markup anchors unless the structure is intentionally replaced with better anchors.
|
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# vv-opencode
|
|
2
|
+
|
|
3
|
+
`@osovv/vv-opencode` - переносимый набор плагинов и CLI для `opencode`.
|
|
4
|
+
|
|
5
|
+
Стартовая цель репозитория:
|
|
6
|
+
|
|
7
|
+
- упаковать `guardian` как npm-плагин для `opencode`
|
|
8
|
+
- добавить CLI `vvoc` для установки, синка и диагностики конфигов
|
|
9
|
+
- сделать перенос workflow между устройствами предсказуемым и идемпотентным
|
|
10
|
+
|
|
11
|
+
## План v1
|
|
12
|
+
|
|
13
|
+
- npm-пакет `@osovv/vv-opencode`
|
|
14
|
+
- bin `vvoc`
|
|
15
|
+
- экспорт `GuardianPlugin`
|
|
16
|
+
- команды `install`, `sync`, `status`, `doctor`, `guardian config`
|
|
17
|
+
|
|
18
|
+
## Локальная разработка
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
bun install
|
|
22
|
+
bun run build
|
|
23
|
+
bun test
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Установка в OpenCode
|
|
27
|
+
|
|
28
|
+
После публикации пакета:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
bunx vvoc install
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
CLI добавит `@osovv/vv-opencode` в `opencode` config и при необходимости создаст `guardian.jsonc`.
|
|
35
|
+
|
|
36
|
+
Эквивалент ручной настройки:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"$schema": "https://opencode.ai/config.json",
|
|
41
|
+
"plugin": ["@osovv/vv-opencode"]
|
|
42
|
+
}
|
|
43
|
+
```
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { defineCommand, runMain } from "citty";
|
|
3
|
+
import doctor from "./commands/doctor.js";
|
|
4
|
+
import guardian from "./commands/guardian.js";
|
|
5
|
+
import install from "./commands/install.js";
|
|
6
|
+
import status from "./commands/status.js";
|
|
7
|
+
import sync from "./commands/sync.js";
|
|
8
|
+
const main = defineCommand({
|
|
9
|
+
meta: {
|
|
10
|
+
name: "vvoc",
|
|
11
|
+
version: "0.1.0",
|
|
12
|
+
description: "Install and sync vv-opencode plugins for OpenCode.",
|
|
13
|
+
},
|
|
14
|
+
subCommands: {
|
|
15
|
+
install,
|
|
16
|
+
sync,
|
|
17
|
+
status,
|
|
18
|
+
doctor,
|
|
19
|
+
guardian,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
await runMain(main);
|
|
23
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,IAAI,MAAM,oBAAoB,CAAC;AAEtC,MAAM,IAAI,GAAG,aAAa,CAAC;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,oDAAoD;KAClE;IACD,WAAW,EAAE;QACX,OAAO;QACP,IAAI;QACJ,MAAM;QACN,MAAM;QACN,QAAQ;KACT;CACF,CAAC,CAAC;AAEH,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const _default: import("citty").CommandDef<{
|
|
2
|
+
readonly scope: {
|
|
3
|
+
readonly type: "enum";
|
|
4
|
+
readonly options: ["global", "project"];
|
|
5
|
+
readonly default: "global";
|
|
6
|
+
readonly description: "Inspect global or project config.";
|
|
7
|
+
};
|
|
8
|
+
readonly source: {
|
|
9
|
+
readonly type: "enum";
|
|
10
|
+
readonly options: ["local", "npm"];
|
|
11
|
+
readonly default: "local";
|
|
12
|
+
readonly description: "Validate local plugin shim or npm package configuration.";
|
|
13
|
+
};
|
|
14
|
+
readonly "config-dir": {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly description: "Override the global OpenCode config directory.";
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
import { inspectInstallation, resolvePaths } from "../lib/opencode.js";
|
|
3
|
+
export default defineCommand({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "doctor",
|
|
6
|
+
description: "Diagnose vv-opencode installation issues.",
|
|
7
|
+
},
|
|
8
|
+
args: {
|
|
9
|
+
scope: {
|
|
10
|
+
type: "enum",
|
|
11
|
+
options: ["global", "project"],
|
|
12
|
+
default: "global",
|
|
13
|
+
description: "Inspect global or project config.",
|
|
14
|
+
},
|
|
15
|
+
source: {
|
|
16
|
+
type: "enum",
|
|
17
|
+
options: ["local", "npm"],
|
|
18
|
+
default: "local",
|
|
19
|
+
description: "Validate local plugin shim or npm package configuration.",
|
|
20
|
+
},
|
|
21
|
+
"config-dir": {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Override the global OpenCode config directory.",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
async run({ args }) {
|
|
27
|
+
const scope = args.scope === "project" ? "project" : "global";
|
|
28
|
+
const configDir = typeof args["config-dir"] === "string" ? args["config-dir"] : undefined;
|
|
29
|
+
const paths = await resolvePaths({
|
|
30
|
+
scope: scope,
|
|
31
|
+
cwd: process.cwd(),
|
|
32
|
+
configDir,
|
|
33
|
+
});
|
|
34
|
+
const inspection = await inspectInstallation(paths);
|
|
35
|
+
const problems = [...inspection.problems];
|
|
36
|
+
if (args.source === "npm") {
|
|
37
|
+
if (!inspection.opencode.packageConfigured) {
|
|
38
|
+
problems.push(`${inspection.opencode.path} does not include ${"@osovv/vv-opencode"}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else if (!inspection.localPlugin.exists) {
|
|
42
|
+
problems.push(`${inspection.localPlugin.path} is missing`);
|
|
43
|
+
}
|
|
44
|
+
console.log(`Scope: ${inspection.scope}`);
|
|
45
|
+
console.log(`OpenCode config: ${inspection.opencode.path}`);
|
|
46
|
+
console.log(`OpenCode config parse: ${inspection.opencode.parseError ? inspection.opencode.parseError : "ok"}`);
|
|
47
|
+
console.log(`Configured plugins: ${inspection.opencode.plugins.length > 0 ? inspection.opencode.plugins.join(", ") : "<none>"}`);
|
|
48
|
+
console.log(`Local plugin shim: ${inspection.localPlugin.path}`);
|
|
49
|
+
console.log(`Local plugin shim state: ${inspection.localPlugin.exists ? inspection.localPlugin.managed ? "managed" : "unmanaged" : "missing"}`);
|
|
50
|
+
console.log(`Guardian config: ${inspection.guardian.path}`);
|
|
51
|
+
console.log(`Guardian config parse: ${inspection.guardian.parseError ? inspection.guardian.parseError : inspection.guardian.exists ? "ok" : "missing"}`);
|
|
52
|
+
console.log(`Guardian config managed by vvoc: ${inspection.guardian.managed ? "yes" : "no"}`);
|
|
53
|
+
if (inspection.warnings.length > 0) {
|
|
54
|
+
console.log("Warnings:");
|
|
55
|
+
for (const warning of inspection.warnings) {
|
|
56
|
+
console.log(`- ${warning}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (problems.length > 0) {
|
|
60
|
+
console.error("Problems:");
|
|
61
|
+
for (const problem of problems) {
|
|
62
|
+
console.error(`- ${problem}`);
|
|
63
|
+
}
|
|
64
|
+
process.exitCode = 1;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
console.log("Doctor: ok");
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAc,MAAM,oBAAoB,CAAC;AAEnF,eAAe,aAAa,CAAC;IAC3B,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,2CAA2C;KACzD;IACD,IAAI,EAAE;QACJ,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;YAC9B,OAAO,EAAE,QAAQ;YACjB,WAAW,EAAE,mCAAmC;SACjD;QACD,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC;YACzB,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,0DAA0D;SACxE;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,gDAAgD;SAC9D;KACF;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,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AAC,WAAW,CAAC,CAAC;YAC3B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC/B,OAAO,CAAC,KAAK,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;YAChC,CAAC;YACD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,OAAO;QACT,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5B,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
import { describeWriteResult, renderGuardianConfig, resolvePaths, writeGuardianConfig, } from "../lib/opencode.js";
|
|
3
|
+
const config = defineCommand({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "config",
|
|
6
|
+
description: "Write or print guardian.jsonc.",
|
|
7
|
+
},
|
|
8
|
+
args: {
|
|
9
|
+
scope: {
|
|
10
|
+
type: "enum",
|
|
11
|
+
options: ["global", "project"],
|
|
12
|
+
default: "global",
|
|
13
|
+
description: "Write global or project Guardian config.",
|
|
14
|
+
},
|
|
15
|
+
"config-dir": {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "Override the global OpenCode config directory.",
|
|
18
|
+
},
|
|
19
|
+
force: {
|
|
20
|
+
type: "boolean",
|
|
21
|
+
description: "Allow overwriting an unmanaged guardian config.",
|
|
22
|
+
},
|
|
23
|
+
print: {
|
|
24
|
+
type: "boolean",
|
|
25
|
+
description: "Print the config instead of writing it.",
|
|
26
|
+
},
|
|
27
|
+
model: {
|
|
28
|
+
type: "string",
|
|
29
|
+
description: "Override the Guardian model.",
|
|
30
|
+
},
|
|
31
|
+
variant: {
|
|
32
|
+
type: "string",
|
|
33
|
+
description: "Override the Guardian variant.",
|
|
34
|
+
},
|
|
35
|
+
"timeout-ms": {
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "Timeout in milliseconds.",
|
|
38
|
+
},
|
|
39
|
+
"approval-risk-threshold": {
|
|
40
|
+
type: "string",
|
|
41
|
+
description: "Approval threshold from 0 to 100.",
|
|
42
|
+
},
|
|
43
|
+
"review-toast-duration-ms": {
|
|
44
|
+
type: "string",
|
|
45
|
+
description: "Toast duration in milliseconds.",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
async run({ args }) {
|
|
49
|
+
const overrides = readGuardianOverridesFromArgs(args);
|
|
50
|
+
if (args.print) {
|
|
51
|
+
process.stdout.write(renderGuardianConfig(overrides));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const scope = args.scope === "project" ? "project" : "global";
|
|
55
|
+
const configDir = typeof args["config-dir"] === "string" ? args["config-dir"] : undefined;
|
|
56
|
+
const paths = await resolvePaths({
|
|
57
|
+
scope: scope,
|
|
58
|
+
cwd: process.cwd(),
|
|
59
|
+
configDir,
|
|
60
|
+
});
|
|
61
|
+
const result = await writeGuardianConfig(paths, overrides, { force: Boolean(args.force) });
|
|
62
|
+
console.log(describeWriteResult(result));
|
|
63
|
+
if (result.action === "skipped") {
|
|
64
|
+
process.exitCode = 1;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
export default defineCommand({
|
|
69
|
+
meta: {
|
|
70
|
+
name: "guardian",
|
|
71
|
+
description: "Guardian-specific helpers.",
|
|
72
|
+
},
|
|
73
|
+
subCommands: {
|
|
74
|
+
config,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
function readGuardianOverridesFromArgs(args) {
|
|
78
|
+
const overrides = {};
|
|
79
|
+
if (typeof args.model === "string" && args.model.trim()) {
|
|
80
|
+
overrides.model = args.model.trim();
|
|
81
|
+
}
|
|
82
|
+
if (typeof args.variant === "string" && args.variant.trim()) {
|
|
83
|
+
overrides.variant = args.variant.trim();
|
|
84
|
+
}
|
|
85
|
+
const timeoutMs = parsePositiveIntegerArg(args["timeout-ms"], "timeout-ms");
|
|
86
|
+
if (timeoutMs !== undefined) {
|
|
87
|
+
overrides.timeoutMs = timeoutMs;
|
|
88
|
+
}
|
|
89
|
+
const approvalRiskThreshold = parseThresholdArg(args["approval-risk-threshold"], "approval-risk-threshold");
|
|
90
|
+
if (approvalRiskThreshold !== undefined) {
|
|
91
|
+
overrides.approvalRiskThreshold = approvalRiskThreshold;
|
|
92
|
+
}
|
|
93
|
+
const reviewToastDurationMs = parsePositiveIntegerArg(args["review-toast-duration-ms"], "review-toast-duration-ms");
|
|
94
|
+
if (reviewToastDurationMs !== undefined) {
|
|
95
|
+
overrides.reviewToastDurationMs = reviewToastDurationMs;
|
|
96
|
+
}
|
|
97
|
+
return overrides;
|
|
98
|
+
}
|
|
99
|
+
function parsePositiveIntegerArg(value, label) {
|
|
100
|
+
if (value === undefined || value === "") {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
const parsed = Number(value);
|
|
104
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
105
|
+
throw new Error(`${label} must be a positive integer`);
|
|
106
|
+
}
|
|
107
|
+
return Math.round(parsed);
|
|
108
|
+
}
|
|
109
|
+
function parseThresholdArg(value, label) {
|
|
110
|
+
if (value === undefined || value === "") {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
const parsed = Number(value);
|
|
114
|
+
if (!Number.isFinite(parsed)) {
|
|
115
|
+
throw new Error(`${label} must be a number`);
|
|
116
|
+
}
|
|
117
|
+
return Math.max(0, Math.min(100, Math.round(parsed)));
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=guardian.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guardian.js","sourceRoot":"","sources":["../../src/commands/guardian.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,GAGpB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,GAAG,aAAa,CAAC;IAC3B,IAAI,EAAE;QACJ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M,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,mBAAmB,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
declare const _default: import("citty").CommandDef<{
|
|
2
|
+
readonly scope: {
|
|
3
|
+
readonly type: "enum";
|
|
4
|
+
readonly options: ["global", "project"];
|
|
5
|
+
readonly default: "global";
|
|
6
|
+
readonly description: "Write to global or project config.";
|
|
7
|
+
};
|
|
8
|
+
readonly source: {
|
|
9
|
+
readonly type: "enum";
|
|
10
|
+
readonly options: ["local", "npm"];
|
|
11
|
+
readonly default: "local";
|
|
12
|
+
readonly description: "Install a local plugin shim or npm package reference.";
|
|
13
|
+
};
|
|
14
|
+
readonly "config-dir": {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly description: "Override the global OpenCode config directory.";
|
|
17
|
+
};
|
|
18
|
+
readonly force: {
|
|
19
|
+
readonly type: "boolean";
|
|
20
|
+
readonly description: "Allow overwriting an existing guardian config when needed.";
|
|
21
|
+
};
|
|
22
|
+
readonly "guardian-config": {
|
|
23
|
+
readonly type: "boolean";
|
|
24
|
+
readonly default: true;
|
|
25
|
+
readonly description: "Create guardian.jsonc when missing.";
|
|
26
|
+
};
|
|
27
|
+
}>;
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
import { describeWriteResult, ensurePackageInstalled, installGuardianConfig, installLocalPlugin, resolvePaths, } from "../lib/opencode.js";
|
|
3
|
+
export default defineCommand({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "install",
|
|
6
|
+
description: "Install vv-opencode into OpenCode config.",
|
|
7
|
+
},
|
|
8
|
+
args: {
|
|
9
|
+
scope: {
|
|
10
|
+
type: "enum",
|
|
11
|
+
options: ["global", "project"],
|
|
12
|
+
default: "global",
|
|
13
|
+
description: "Write to global or project config.",
|
|
14
|
+
},
|
|
15
|
+
source: {
|
|
16
|
+
type: "enum",
|
|
17
|
+
options: ["local", "npm"],
|
|
18
|
+
default: "local",
|
|
19
|
+
description: "Install a local plugin shim or npm package reference.",
|
|
20
|
+
},
|
|
21
|
+
"config-dir": {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Override the global OpenCode config directory.",
|
|
24
|
+
},
|
|
25
|
+
force: {
|
|
26
|
+
type: "boolean",
|
|
27
|
+
description: "Allow overwriting an existing guardian config when needed.",
|
|
28
|
+
},
|
|
29
|
+
"guardian-config": {
|
|
30
|
+
type: "boolean",
|
|
31
|
+
default: true,
|
|
32
|
+
description: "Create guardian.jsonc when missing.",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
async run({ args }) {
|
|
36
|
+
const scope = args.scope === "project" ? "project" : "global";
|
|
37
|
+
const configDir = typeof args["config-dir"] === "string" ? args["config-dir"] : undefined;
|
|
38
|
+
const paths = await resolvePaths({
|
|
39
|
+
scope: scope,
|
|
40
|
+
cwd: process.cwd(),
|
|
41
|
+
configDir,
|
|
42
|
+
});
|
|
43
|
+
if (args.source === "npm") {
|
|
44
|
+
const opencode = await ensurePackageInstalled(paths);
|
|
45
|
+
console.log(`${opencode.changed ? "Updated" : "Kept"} ${opencode.path}`);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const localPlugin = await installLocalPlugin(paths, { force: Boolean(args.force) });
|
|
49
|
+
console.log(describeWriteResult(localPlugin));
|
|
50
|
+
}
|
|
51
|
+
if (args["guardian-config"] === false) {
|
|
52
|
+
console.log(`Skipped ${paths.guardianConfigPath} (guardian config disabled)`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const guardian = await installGuardianConfig(paths, { force: Boolean(args.force) });
|
|
56
|
+
console.log(describeWriteResult(guardian));
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,YAAY,GAEb,MAAM,oBAAoB,CAAC;AAE5B,eAAe,aAAa,CAAC;IAC3B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,2CAA2C;KACzD;IACD,IAAI,EAAE;QACJ,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;YAC9B,OAAO,EAAE,QAAQ;YACjB,WAAW,EAAE,oCAAoC;SAClD;QACD,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC;YACzB,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,uDAAuD;SACrE;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,gDAAgD;SAC9D;QACD,KAAK,EAAE;YACL,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,4DAA4D;SAC1E;QACD,iBAAiB,EAAE;YACjB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,qCAAqC;SACnD;KACF;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC9D,MAAM,SAAS,GAAG,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,QAAQ,CAAC,CAAC,CA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|
+
readonly default: "global";
|
|
6
|
+
readonly description: "Inspect global or project config.";
|
|
7
|
+
};
|
|
8
|
+
readonly "config-dir": {
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly description: "Override the global OpenCode config directory.";
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { defineCommand } from "citty";
|
|
2
|
+
import { inspectInstallation, resolvePaths } from "../lib/opencode.js";
|
|
3
|
+
export default defineCommand({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "status",
|
|
6
|
+
description: "Show vv-opencode installation status.",
|
|
7
|
+
},
|
|
8
|
+
args: {
|
|
9
|
+
scope: {
|
|
10
|
+
type: "enum",
|
|
11
|
+
options: ["global", "project"],
|
|
12
|
+
default: "global",
|
|
13
|
+
description: "Inspect global or project config.",
|
|
14
|
+
},
|
|
15
|
+
"config-dir": {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "Override the global OpenCode config directory.",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
async run({ args }) {
|
|
21
|
+
const scope = args.scope === "project" ? "project" : "global";
|
|
22
|
+
const configDir = typeof args["config-dir"] === "string" ? args["config-dir"] : undefined;
|
|
23
|
+
const paths = await resolvePaths({
|
|
24
|
+
scope: scope,
|
|
25
|
+
cwd: process.cwd(),
|
|
26
|
+
configDir,
|
|
27
|
+
});
|
|
28
|
+
const inspection = await inspectInstallation(paths);
|
|
29
|
+
console.log(`Scope: ${inspection.scope}`);
|
|
30
|
+
console.log(`OpenCode config: ${inspection.opencode.path}`);
|
|
31
|
+
console.log(`OpenCode config exists: ${inspection.opencode.exists ? "yes" : "no"}`);
|
|
32
|
+
console.log(`Package configured in opencode.json: ${inspection.opencode.packageConfigured ? "yes" : "no"}`);
|
|
33
|
+
console.log(`Local plugin shim: ${inspection.localPlugin.path}`);
|
|
34
|
+
console.log(`Local plugin shim exists: ${inspection.localPlugin.exists ? "yes" : "no"}`);
|
|
35
|
+
console.log(`Local plugin shim managed by vvoc: ${inspection.localPlugin.managed ? "yes" : "no"}`);
|
|
36
|
+
console.log(`Guardian config: ${inspection.guardian.path}`);
|
|
37
|
+
console.log(`Guardian config exists: ${inspection.guardian.exists ? "yes" : "no"}`);
|
|
38
|
+
console.log(`Guardian config managed by vvoc: ${inspection.guardian.managed ? "yes" : "no"}`);
|
|
39
|
+
if (inspection.warnings.length > 0) {
|
|
40
|
+
console.log("Warnings:");
|
|
41
|
+
for (const warning of inspection.warnings) {
|
|
42
|
+
console.log(`- ${warning}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAc,MAAM,oBAAoB,CAAC;AAEnF,eAAe,aAAa,CAAC;IAC3B,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,uCAAuC;KACrD;IACD,IAAI,EAAE;QACJ,KAAK,EAAE;YACL,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;YAC9B,OAAO,EAAE,QAAQ;YACjB,WAAW,EAAE,mCAAmC;SACjD;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,gDAAgD;SAC9D;KACF;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC9D,MAAM,SAAS,GAAG,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,QAAQ,CA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AAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACpF,OAAO,CAAC,GAAG,CAAC,oCAAoC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAE9F,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACzB,KAAK,MAAM,OAAO,IAAI,UAAU,CAAC,QAAQ,EAAE,CAAC;gBAC1C,OAAO,CAAC,GAAG,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare const _default: import("citty").CommandDef<{
|
|
2
|
+
readonly scope: {
|
|
3
|
+
readonly type: "enum";
|
|
4
|
+
readonly options: ["global", "project"];
|
|
5
|
+
readonly default: "global";
|
|
6
|
+
readonly description: "Sync global or project config.";
|
|
7
|
+
};
|
|
8
|
+
readonly source: {
|
|
9
|
+
readonly type: "enum";
|
|
10
|
+
readonly options: ["local", "npm"];
|
|
11
|
+
readonly default: "local";
|
|
12
|
+
readonly description: "Sync a local plugin shim or npm package reference.";
|
|
13
|
+
};
|
|
14
|
+
readonly "config-dir": {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly description: "Override the global OpenCode config directory.";
|
|
17
|
+
};
|
|
18
|
+
readonly force: {
|
|
19
|
+
readonly type: "boolean";
|
|
20
|
+
readonly description: "Allow rewriting unmanaged guardian config files.";
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
export default _default;
|