@dotdotgod/opencode 0.0.0-stage → 0.6.6
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 +94 -0
- package/README.md +84 -2
- package/commands/impact.md +26 -0
- package/commands/init.md +38 -0
- package/commands/load.md +28 -0
- package/index.js +1 -0
- package/mcp/cli.mjs +7017 -0
- package/mcp/impact-state.mjs +133 -0
- package/mcp/parsers/IGNORE_LICENSE +21 -0
- package/mcp/parsers/LICENSE +21 -0
- package/mcp/parsers/TYPESCRIPT_LICENSE +21 -0
- package/mcp/parsers/tree-sitter-bash.wasm +0 -0
- package/mcp/parsers/tree-sitter-c-sharp.wasm +0 -0
- package/mcp/parsers/tree-sitter-cpp.wasm +0 -0
- package/mcp/parsers/tree-sitter-css.wasm +0 -0
- package/mcp/parsers/tree-sitter-go.wasm +0 -0
- package/mcp/parsers/tree-sitter-ini.wasm +0 -0
- package/mcp/parsers/tree-sitter-java.wasm +0 -0
- package/mcp/parsers/tree-sitter-javascript.wasm +0 -0
- package/mcp/parsers/tree-sitter-php.wasm +0 -0
- package/mcp/parsers/tree-sitter-powershell.wasm +0 -0
- package/mcp/parsers/tree-sitter-python.wasm +0 -0
- package/mcp/parsers/tree-sitter-regex.wasm +0 -0
- package/mcp/parsers/tree-sitter-ruby.wasm +0 -0
- package/mcp/parsers/tree-sitter-rust.wasm +0 -0
- package/mcp/parsers/tree-sitter-tsx.wasm +0 -0
- package/mcp/parsers/tree-sitter-typescript.wasm +0 -0
- package/mcp/parsers/tree-sitter.cjs +4075 -0
- package/mcp/parsers/tree-sitter.wasm +0 -0
- package/mcp/server.mjs +23716 -0
- package/package.json +41 -3
- package/server.js +1 -0
- package/skills/doc-first-planning/SKILL.md +30 -0
- package/skills/document-clarify/SKILL.md +41 -0
- package/skills/impact-review/SKILL.md +25 -0
- package/skills/project-initializer/SKILL.md +37 -0
- package/skills/project-initializer/references/agent-docs.md +42 -0
- package/skills/project-initializer/scripts/init_project.sh +525 -0
- package/skills/project-initializer/templates/case-and-evidence.json +219 -0
- package/skills/project-initializer/templates/dotdotgod.config.json +234 -0
- package/skills/project-initializer/templates/policy.json +241 -0
- package/skills/project-initializer/templates/portfolio.json +255 -0
- package/skills/project-initializer/templates/publication.json +265 -0
- package/skills/project-initializer/templates/research.json +287 -0
- package/skills/project-initializer/templates/software.json +234 -0
- package/skills/project-load/SKILL.md +27 -0
- package/src/impact.mjs +25 -0
- package/src/index.mjs +17 -0
- package/src/location.mjs +7 -0
- package/src/mcp.mjs +37 -0
- package/src/plan.mjs +65 -0
- package/src/resources.mjs +28 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// packages/context/src/impact-state.mjs
|
|
2
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, realpathSync } from "node:fs";
|
|
4
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
5
|
+
import { DatabaseSync } from "node:sqlite";
|
|
6
|
+
|
|
7
|
+
// packages/context/src/session.mjs
|
|
8
|
+
var SESSION_ID = /^[A-Za-z0-9][A-Za-z0-9._~-]{0,127}$/;
|
|
9
|
+
function validateSessionId(value) {
|
|
10
|
+
if (typeof value !== "string" || !SESSION_ID.test(value)) {
|
|
11
|
+
throw new TypeError("sessionId must be an opaque 1-128 character identifier using letters, digits, dot, underscore, tilde, or hyphen.");
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// packages/context/src/retention.mjs
|
|
17
|
+
var RETENTION_MS = 24 * 60 * 60 * 1e3;
|
|
18
|
+
|
|
19
|
+
// packages/context/src/impact-state.mjs
|
|
20
|
+
function impactPath(root, path) {
|
|
21
|
+
if (typeof path !== "string" || !path.trim() || path.includes("\0")) return void 0;
|
|
22
|
+
const absolute = resolve(root, path);
|
|
23
|
+
const name = relative(resolve(root), absolute).replaceAll("\\", "/");
|
|
24
|
+
if (!name || name === ".." || name.startsWith("../") || isAbsolute(name)) return void 0;
|
|
25
|
+
if (/(^|\/)(node_modules|\.git|\.dotdotgod|dist|build|coverage)(\/|$)/.test(name)) return void 0;
|
|
26
|
+
if (/^docs\/(plan|archive)(\/|$)/.test(name)) return void 0;
|
|
27
|
+
let ancestor = absolute;
|
|
28
|
+
while (!existsSync(ancestor) && dirname(ancestor) !== ancestor) ancestor = dirname(ancestor);
|
|
29
|
+
const realRelative = relative(realpathSync(root), realpathSync(ancestor));
|
|
30
|
+
if (realRelative === ".." || realRelative.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) || isAbsolute(realRelative)) return void 0;
|
|
31
|
+
return name;
|
|
32
|
+
}
|
|
33
|
+
function impactFingerprint(root, path) {
|
|
34
|
+
try {
|
|
35
|
+
return createHash("sha256").update(readFileSync(resolve(root, path))).digest("hex");
|
|
36
|
+
} catch (error) {
|
|
37
|
+
return error.code === "ENOENT" ? "missing" : void 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
var ImpactState = class {
|
|
41
|
+
constructor(root, sessionId) {
|
|
42
|
+
this.root = resolve(root);
|
|
43
|
+
this.sessionId = validateSessionId(sessionId);
|
|
44
|
+
this.path = join(this.root, ".dotdotgod/context/impact.sqlite");
|
|
45
|
+
}
|
|
46
|
+
database(write = false) {
|
|
47
|
+
if (!write && !existsSync(this.path)) return void 0;
|
|
48
|
+
if (write) mkdirSync(dirname(this.path), { recursive: true });
|
|
49
|
+
const db = new DatabaseSync(this.path);
|
|
50
|
+
db.exec("PRAGMA busy_timeout=5000");
|
|
51
|
+
db.exec("CREATE TABLE IF NOT EXISTS pending (session TEXT NOT NULL, path TEXT NOT NULL, revision TEXT NOT NULL, fingerprint TEXT, PRIMARY KEY(session,path))");
|
|
52
|
+
db.exec("BEGIN IMMEDIATE");
|
|
53
|
+
try {
|
|
54
|
+
const columns = db.prepare("PRAGMA table_info(pending)").all();
|
|
55
|
+
if (!columns.some((column) => column.name === "expires_at")) {
|
|
56
|
+
db.exec("ALTER TABLE pending ADD COLUMN created_at INTEGER; ALTER TABLE pending ADD COLUMN expires_at INTEGER;");
|
|
57
|
+
const now = Date.now();
|
|
58
|
+
db.prepare("UPDATE pending SET created_at = ?, expires_at = ?").run(now, now + RETENTION_MS);
|
|
59
|
+
}
|
|
60
|
+
db.prepare("DELETE FROM pending WHERE expires_at <= ?").run(Date.now());
|
|
61
|
+
db.exec("COMMIT");
|
|
62
|
+
} catch (error) {
|
|
63
|
+
db.exec("ROLLBACK");
|
|
64
|
+
db.close();
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
return db;
|
|
68
|
+
}
|
|
69
|
+
mark(paths) {
|
|
70
|
+
const names = [...new Set(paths.map((path) => impactPath(this.root, path)).filter(Boolean))];
|
|
71
|
+
if (!names.length) return;
|
|
72
|
+
const db = this.database(true);
|
|
73
|
+
try {
|
|
74
|
+
const insert = db.prepare("INSERT OR REPLACE INTO pending (session,path,revision,fingerprint,created_at,expires_at) VALUES (?, ?, ?, ?, ?, ?)");
|
|
75
|
+
db.exec("BEGIN IMMEDIATE");
|
|
76
|
+
const now = Date.now();
|
|
77
|
+
for (const path of names) insert.run(this.sessionId, path, randomUUID(), impactFingerprint(this.root, path) ?? null, now, now + RETENTION_MS);
|
|
78
|
+
db.exec("COMMIT");
|
|
79
|
+
} finally {
|
|
80
|
+
db.close();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
snapshot(paths) {
|
|
84
|
+
const selected = paths ? new Set(paths.map((path) => impactPath(this.root, path)).filter(Boolean)) : void 0;
|
|
85
|
+
const db = this.database();
|
|
86
|
+
if (!db) return [];
|
|
87
|
+
try {
|
|
88
|
+
return db.prepare("SELECT path,revision,fingerprint FROM pending WHERE session=? ORDER BY path").all(this.sessionId).filter((item) => !selected || selected.has(item.path));
|
|
89
|
+
} finally {
|
|
90
|
+
db.close();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
complete(snapshot) {
|
|
94
|
+
if (!snapshot.length) return;
|
|
95
|
+
const db = this.database();
|
|
96
|
+
if (!db) return;
|
|
97
|
+
try {
|
|
98
|
+
const remove = db.prepare("DELETE FROM pending WHERE session=? AND path=? AND revision=?");
|
|
99
|
+
for (const item of snapshot) {
|
|
100
|
+
if (item.fingerprint && impactFingerprint(this.root, item.path) === item.fingerprint) remove.run(this.sessionId, item.path, item.revision);
|
|
101
|
+
}
|
|
102
|
+
} finally {
|
|
103
|
+
db.close();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
status(limit = 50) {
|
|
107
|
+
const all = this.snapshot();
|
|
108
|
+
return { ok: true, count: all.length, pending: all.slice(0, limit).map(({ path }) => ({ path })), truncated: all.length > limit };
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
async function withImpactReview(root, sessionId, paths, review, signal) {
|
|
112
|
+
signal?.throwIfAborted();
|
|
113
|
+
const state = new ImpactState(root, sessionId);
|
|
114
|
+
const snapshot = state.snapshot(paths).map((item) => ({ ...item, fingerprint: impactFingerprint(root, item.path) }));
|
|
115
|
+
const result = await review();
|
|
116
|
+
signal?.throwIfAborted();
|
|
117
|
+
if (result.ok === true) state.complete(snapshot);
|
|
118
|
+
return { ...result, checked: result.ok === true ? paths : [], impactStatus: state.status() };
|
|
119
|
+
}
|
|
120
|
+
function impactReminder(status) {
|
|
121
|
+
if (!status.count) return void 0;
|
|
122
|
+
return `[DOTDOTGOD IMPACT PENDING \u2014 ADVISORY]
|
|
123
|
+
${status.count} changed file(s) await impact review:
|
|
124
|
+
${status.pending.slice(0, 8).map((item) => `- ${item.path}`).join("\n")}
|
|
125
|
+
Run project_impact from the dotdotgod_context MCP server for the relevant paths and review related evidence. Pending impact does not block edits, tests, builds, commits, or other tools. Only observed edits are tracked; shell, external, and unobserved changes may require explicit paths.`;
|
|
126
|
+
}
|
|
127
|
+
export {
|
|
128
|
+
ImpactState,
|
|
129
|
+
impactFingerprint,
|
|
130
|
+
impactPath,
|
|
131
|
+
impactReminder,
|
|
132
|
+
withImpactReview
|
|
133
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Copyright (c) 2013 Kael Zhang <i@kael.me>, contributors
|
|
2
|
+
http://kael.me/
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
5
|
+
a copy of this software and associated documentation files (the
|
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
10
|
+
the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be
|
|
13
|
+
included in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
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
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Max Brunsfeld
|
|
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.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|