@pdxxxx/keel 0.0.0-stage → 1.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/ARCHITECTURE.md +101 -0
- package/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/README.md +143 -2
- package/README_CN.md +144 -0
- package/bin/keel.js +4 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +569 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/ablate.d.ts +11 -0
- package/dist/core/ablate.js +54 -0
- package/dist/core/ablate.js.map +1 -0
- package/dist/core/config.d.ts +3 -0
- package/dist/core/config.js +60 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/git.d.ts +9 -0
- package/dist/core/git.js +48 -0
- package/dist/core/git.js.map +1 -0
- package/dist/core/glob.d.ts +8 -0
- package/dist/core/glob.js +61 -0
- package/dist/core/glob.js.map +1 -0
- package/dist/core/hotspots.d.ts +11 -0
- package/dist/core/hotspots.js +49 -0
- package/dist/core/hotspots.js.map +1 -0
- package/dist/core/init.d.ts +14 -0
- package/dist/core/init.js +117 -0
- package/dist/core/init.js.map +1 -0
- package/dist/core/mcp.d.ts +24 -0
- package/dist/core/mcp.js +323 -0
- package/dist/core/mcp.js.map +1 -0
- package/dist/core/mem.d.ts +21 -0
- package/dist/core/mem.js +337 -0
- package/dist/core/mem.js.map +1 -0
- package/dist/core/migrate.d.ts +21 -0
- package/dist/core/migrate.js +207 -0
- package/dist/core/migrate.js.map +1 -0
- package/dist/core/paths.d.ts +14 -0
- package/dist/core/paths.js +44 -0
- package/dist/core/paths.js.map +1 -0
- package/dist/core/rules.d.ts +22 -0
- package/dist/core/rules.js +262 -0
- package/dist/core/rules.js.map +1 -0
- package/dist/core/snapshot.d.ts +30 -0
- package/dist/core/snapshot.js +212 -0
- package/dist/core/snapshot.js.map +1 -0
- package/dist/core/tasks.d.ts +13 -0
- package/dist/core/tasks.js +180 -0
- package/dist/core/tasks.js.map +1 -0
- package/dist/core/types.d.ts +98 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/verify.d.ts +8 -0
- package/dist/core/verify.js +66 -0
- package/dist/core/verify.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/templates/assets.d.ts +11 -0
- package/dist/templates/assets.js +179 -0
- package/dist/templates/assets.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/package.json +67 -4
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { ARCHIVE_DIR, keelPath, TASKS_DIR, toPosixPath } from "./paths.js";
|
|
4
|
+
function slugify(input) {
|
|
5
|
+
return input
|
|
6
|
+
.toLowerCase()
|
|
7
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
8
|
+
.replace(/^-+|-+$/g, "")
|
|
9
|
+
.slice(0, 48);
|
|
10
|
+
}
|
|
11
|
+
function formatDatePrefix(date) {
|
|
12
|
+
const y = date.getFullYear();
|
|
13
|
+
const m = String(date.getMonth() + 1).padStart(2, "0");
|
|
14
|
+
const d = String(date.getDate()).padStart(2, "0");
|
|
15
|
+
return `${y}-${m}-${d}`;
|
|
16
|
+
}
|
|
17
|
+
function taskDirectory(repoRoot, id) {
|
|
18
|
+
const parts = id.split(/[\\/]/).filter((part) => part !== "" && part !== ".");
|
|
19
|
+
if (/^[\\/]/.test(id) || id.includes("\0") || parts.length === 0 ||
|
|
20
|
+
parts.some((part) => part === ".." || /^[a-z]:/i.test(part))) {
|
|
21
|
+
throw new Error(`Task not found: ${id}`);
|
|
22
|
+
}
|
|
23
|
+
return keelPath(repoRoot, TASKS_DIR, parts.join("/"));
|
|
24
|
+
}
|
|
25
|
+
function readTaskMeta(taskDir) {
|
|
26
|
+
const metaPath = path.join(taskDir, "meta.json");
|
|
27
|
+
if (!fs.existsSync(metaPath))
|
|
28
|
+
return null;
|
|
29
|
+
try {
|
|
30
|
+
const raw = JSON.parse(fs.readFileSync(metaPath, "utf-8"));
|
|
31
|
+
if (typeof raw.id !== "string" ||
|
|
32
|
+
typeof raw.title !== "string" ||
|
|
33
|
+
(raw.status !== "open" && raw.status !== "done")) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
id: raw.id,
|
|
38
|
+
title: raw.title,
|
|
39
|
+
status: raw.status,
|
|
40
|
+
createdAt: typeof raw.createdAt === "string" ? raw.createdAt : "",
|
|
41
|
+
updatedAt: typeof raw.updatedAt === "string" ? raw.updatedAt : "",
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export function createTask(repoRoot, title, options = {}) {
|
|
49
|
+
const trimmedTitle = title.trim();
|
|
50
|
+
if (!trimmedTitle) {
|
|
51
|
+
throw new Error("Task title cannot be empty.");
|
|
52
|
+
}
|
|
53
|
+
const now = options.now ?? new Date();
|
|
54
|
+
const slug = slugify(options.slug?.trim() || trimmedTitle) || "task";
|
|
55
|
+
const baseId = `${formatDatePrefix(now)}-${slug}`;
|
|
56
|
+
const tasksRoot = keelPath(repoRoot, TASKS_DIR);
|
|
57
|
+
fs.mkdirSync(tasksRoot, { recursive: true });
|
|
58
|
+
let id = baseId;
|
|
59
|
+
let counter = 2;
|
|
60
|
+
while (fs.existsSync(path.join(tasksRoot, id))) {
|
|
61
|
+
id = `${baseId}-${counter}`;
|
|
62
|
+
counter += 1;
|
|
63
|
+
}
|
|
64
|
+
const taskDir = path.join(tasksRoot, id);
|
|
65
|
+
fs.mkdirSync(taskDir, { recursive: true });
|
|
66
|
+
const timestamp = now.toISOString();
|
|
67
|
+
const meta = {
|
|
68
|
+
id,
|
|
69
|
+
title: trimmedTitle,
|
|
70
|
+
status: "open",
|
|
71
|
+
createdAt: timestamp,
|
|
72
|
+
updatedAt: timestamp,
|
|
73
|
+
};
|
|
74
|
+
const specContent = `# ${trimmedTitle}
|
|
75
|
+
|
|
76
|
+
## Goal
|
|
77
|
+
|
|
78
|
+
- What problem are we solving?
|
|
79
|
+
|
|
80
|
+
## Non-Goals
|
|
81
|
+
|
|
82
|
+
- What is explicitly out of scope?
|
|
83
|
+
|
|
84
|
+
## Acceptance Criteria
|
|
85
|
+
|
|
86
|
+
- [ ] Concrete, verifiable outcome
|
|
87
|
+
|
|
88
|
+
## Decisions & Notes
|
|
89
|
+
|
|
90
|
+
- Record tradeoffs or links to \`research/\` notes here so they survive session compaction.
|
|
91
|
+
`;
|
|
92
|
+
fs.writeFileSync(path.join(taskDir, "meta.json"), `${JSON.stringify(meta, null, 2)}\n`, "utf-8");
|
|
93
|
+
fs.writeFileSync(path.join(taskDir, "spec.md"), specContent, "utf-8");
|
|
94
|
+
return {
|
|
95
|
+
...meta,
|
|
96
|
+
dir: toPosixPath(path.relative(repoRoot, taskDir)),
|
|
97
|
+
specFile: toPosixPath(path.relative(repoRoot, path.join(taskDir, "spec.md"))),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export function listTasks(repoRoot, options = {}) {
|
|
101
|
+
const tasksRoot = keelPath(repoRoot, TASKS_DIR);
|
|
102
|
+
if (!fs.existsSync(tasksRoot))
|
|
103
|
+
return [];
|
|
104
|
+
const dirsToScan = [tasksRoot];
|
|
105
|
+
if (options.includeArchived) {
|
|
106
|
+
const archiveRoot = path.join(tasksRoot, ARCHIVE_DIR);
|
|
107
|
+
if (fs.existsSync(archiveRoot)) {
|
|
108
|
+
dirsToScan.push(archiveRoot);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const records = [];
|
|
112
|
+
for (const baseDir of dirsToScan) {
|
|
113
|
+
for (const entry of fs.readdirSync(baseDir, { withFileTypes: true })) {
|
|
114
|
+
if (!entry.isDirectory())
|
|
115
|
+
continue;
|
|
116
|
+
if (baseDir === tasksRoot && entry.name === ARCHIVE_DIR)
|
|
117
|
+
continue;
|
|
118
|
+
const fullDir = path.join(baseDir, entry.name);
|
|
119
|
+
const meta = readTaskMeta(fullDir);
|
|
120
|
+
if (!meta)
|
|
121
|
+
continue;
|
|
122
|
+
if (options.status && meta.status !== options.status)
|
|
123
|
+
continue;
|
|
124
|
+
records.push({
|
|
125
|
+
...meta,
|
|
126
|
+
dir: toPosixPath(path.relative(repoRoot, fullDir)),
|
|
127
|
+
specFile: toPosixPath(path.relative(repoRoot, path.join(fullDir, "spec.md"))),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return records.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
132
|
+
}
|
|
133
|
+
export function getTask(repoRoot, id) {
|
|
134
|
+
const taskDir = taskDirectory(repoRoot, id);
|
|
135
|
+
const meta = readTaskMeta(taskDir);
|
|
136
|
+
if (!meta) {
|
|
137
|
+
throw new Error(`Task not found: ${id}`);
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
...meta,
|
|
141
|
+
dir: toPosixPath(path.relative(repoRoot, taskDir)),
|
|
142
|
+
specFile: toPosixPath(path.relative(repoRoot, path.join(taskDir, "spec.md"))),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export function setTaskStatus(repoRoot, id, status, now = new Date()) {
|
|
146
|
+
const taskDir = taskDirectory(repoRoot, id);
|
|
147
|
+
const meta = readTaskMeta(taskDir);
|
|
148
|
+
if (!meta) {
|
|
149
|
+
throw new Error(`Task not found: ${id}`);
|
|
150
|
+
}
|
|
151
|
+
const updated = {
|
|
152
|
+
...meta,
|
|
153
|
+
status,
|
|
154
|
+
updatedAt: now.toISOString(),
|
|
155
|
+
};
|
|
156
|
+
fs.writeFileSync(path.join(taskDir, "meta.json"), `${JSON.stringify(updated, null, 2)}\n`, "utf-8");
|
|
157
|
+
return {
|
|
158
|
+
...updated,
|
|
159
|
+
dir: toPosixPath(path.relative(repoRoot, taskDir)),
|
|
160
|
+
specFile: toPosixPath(path.relative(repoRoot, path.join(taskDir, "spec.md"))),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
export function archiveTask(repoRoot, id, now = new Date()) {
|
|
164
|
+
const updated = setTaskStatus(repoRoot, id, "done", now);
|
|
165
|
+
const tasksRoot = keelPath(repoRoot, TASKS_DIR);
|
|
166
|
+
const sourceDir = path.join(repoRoot, updated.dir);
|
|
167
|
+
const archiveRoot = path.join(tasksRoot, ARCHIVE_DIR);
|
|
168
|
+
fs.mkdirSync(archiveRoot, { recursive: true });
|
|
169
|
+
const destDir = path.join(archiveRoot, path.relative(tasksRoot, sourceDir));
|
|
170
|
+
if (fs.existsSync(destDir)) {
|
|
171
|
+
throw new Error(`Archived task already exists: ${id}`);
|
|
172
|
+
}
|
|
173
|
+
fs.renameSync(sourceDir, destDir);
|
|
174
|
+
return {
|
|
175
|
+
...updated,
|
|
176
|
+
dir: toPosixPath(path.relative(repoRoot, destDir)),
|
|
177
|
+
specFile: toPosixPath(path.relative(repoRoot, path.join(destDir, "spec.md"))),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=tasks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../src/core/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG3E,SAAS,OAAO,CAAC,KAAa;IAC5B,OAAO,KAAK;SACT,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,gBAAgB,CAAC,IA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AI,EAAE,CAAC,CAAC;IAE/C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IAC5E,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,iCAAiC,EAAE,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,EAAE,CAAC,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAElC,OAAO;QACL,GAAG,OAAO;QACV,GAAG,EAAE,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClD,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;KAC9E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export type RuleSeverity = "invariant" | "guideline" | "adr";
|
|
2
|
+
export interface RuleEntry {
|
|
3
|
+
id: string;
|
|
4
|
+
file: string;
|
|
5
|
+
summary: string;
|
|
6
|
+
severity: RuleSeverity;
|
|
7
|
+
paths: string[];
|
|
8
|
+
global: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface RuleIssue {
|
|
11
|
+
file: string;
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
14
|
+
export interface RuleValidationReport {
|
|
15
|
+
valid: boolean;
|
|
16
|
+
checked: number;
|
|
17
|
+
issues: RuleIssue[];
|
|
18
|
+
warnings?: RuleIssue[];
|
|
19
|
+
}
|
|
20
|
+
export type TaskStatus = "open" | "done";
|
|
21
|
+
export interface TaskMeta {
|
|
22
|
+
id: string;
|
|
23
|
+
title: string;
|
|
24
|
+
status: TaskStatus;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
updatedAt: string;
|
|
27
|
+
}
|
|
28
|
+
export interface TaskRecord extends TaskMeta {
|
|
29
|
+
dir: string;
|
|
30
|
+
specFile: string;
|
|
31
|
+
}
|
|
32
|
+
export interface VerifyGateConfig {
|
|
33
|
+
name: string;
|
|
34
|
+
command: string;
|
|
35
|
+
cwd?: string;
|
|
36
|
+
paths?: string[];
|
|
37
|
+
}
|
|
38
|
+
export interface MemoryConfig {
|
|
39
|
+
sources: string[];
|
|
40
|
+
}
|
|
41
|
+
export interface KeelConfig {
|
|
42
|
+
version: number;
|
|
43
|
+
verify: {
|
|
44
|
+
gates: VerifyGateConfig[];
|
|
45
|
+
};
|
|
46
|
+
memory: MemoryConfig;
|
|
47
|
+
}
|
|
48
|
+
export interface VerifyGateResult {
|
|
49
|
+
name: string;
|
|
50
|
+
command: string;
|
|
51
|
+
passed: boolean;
|
|
52
|
+
exitCode: number;
|
|
53
|
+
durationMs: number;
|
|
54
|
+
output: string;
|
|
55
|
+
}
|
|
56
|
+
export interface VerifyReport {
|
|
57
|
+
passed: boolean;
|
|
58
|
+
gates: VerifyGateResult[];
|
|
59
|
+
skipped?: string[];
|
|
60
|
+
}
|
|
61
|
+
export interface MemoryTurn {
|
|
62
|
+
role: "user" | "assistant" | "artifact";
|
|
63
|
+
text: string;
|
|
64
|
+
timestamp?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface MemorySessionSummary {
|
|
67
|
+
id: string;
|
|
68
|
+
source: string;
|
|
69
|
+
file: string;
|
|
70
|
+
title: string;
|
|
71
|
+
updatedAt: string;
|
|
72
|
+
turnCount: number;
|
|
73
|
+
}
|
|
74
|
+
export interface MemorySearchHit {
|
|
75
|
+
sessionId: string;
|
|
76
|
+
source: string;
|
|
77
|
+
file: string;
|
|
78
|
+
role: MemoryTurn["role"];
|
|
79
|
+
score: number;
|
|
80
|
+
snippet: string;
|
|
81
|
+
timestamp?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface AblateManifestEntry {
|
|
84
|
+
kind: "file" | "agents-block" | "config-edit";
|
|
85
|
+
relativePath: string;
|
|
86
|
+
originalSha256: string;
|
|
87
|
+
postAblateSha256: string | null;
|
|
88
|
+
backupRelPath: string;
|
|
89
|
+
originalMode?: number;
|
|
90
|
+
}
|
|
91
|
+
export interface AblateManifest {
|
|
92
|
+
version: 1;
|
|
93
|
+
repoRoot: string;
|
|
94
|
+
createdAt: string;
|
|
95
|
+
entries: AblateManifestEntry[];
|
|
96
|
+
directories?: string[];
|
|
97
|
+
operation?: "migrate";
|
|
98
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type GitChangedOptions } from "./git.js";
|
|
2
|
+
import type { VerifyReport } from "./types.js";
|
|
3
|
+
export interface RunVerifyOptions extends GitChangedOptions {
|
|
4
|
+
git?: boolean;
|
|
5
|
+
gateNames?: string[];
|
|
6
|
+
failFast?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function runVerify(repoRoot: string, options?: RunVerifyOptions): VerifyReport;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { loadConfig } from "./config.js";
|
|
4
|
+
import { getGitChangedFiles } from "./git.js";
|
|
5
|
+
import { matchesAnyPath } from "./glob.js";
|
|
6
|
+
export function runVerify(repoRoot, options = {}) {
|
|
7
|
+
const config = loadConfig(repoRoot);
|
|
8
|
+
const requested = options.gateNames?.filter((n) => n.trim().length > 0) ?? [];
|
|
9
|
+
let gatesToRun = requested.length > 0
|
|
10
|
+
? config.verify.gates.filter((g) => requested.includes(g.name))
|
|
11
|
+
: config.verify.gates;
|
|
12
|
+
let skipped;
|
|
13
|
+
if (requested.length > 0) {
|
|
14
|
+
const foundNames = new Set(gatesToRun.map((g) => g.name));
|
|
15
|
+
const missing = requested.filter((name) => !foundNames.has(name));
|
|
16
|
+
if (missing.length > 0) {
|
|
17
|
+
throw new Error(`Unknown verification gate(s): ${missing.join(", ")}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else if (options.git || options.staged || options.baseRef) {
|
|
21
|
+
const changes = getGitChangedFiles(repoRoot, options);
|
|
22
|
+
const unmatched = [];
|
|
23
|
+
gatesToRun = gatesToRun.filter((gate) => {
|
|
24
|
+
if (!gate.paths?.length || gate.paths.some((pattern) => matchesAnyPath(pattern, changes)))
|
|
25
|
+
return true;
|
|
26
|
+
unmatched.push(gate.name);
|
|
27
|
+
return false;
|
|
28
|
+
});
|
|
29
|
+
skipped = unmatched;
|
|
30
|
+
}
|
|
31
|
+
const results = [];
|
|
32
|
+
for (const gate of gatesToRun) {
|
|
33
|
+
const start = Date.now();
|
|
34
|
+
const cwd = gate.cwd ? path.resolve(repoRoot, gate.cwd) : repoRoot;
|
|
35
|
+
const proc = spawnSync(gate.command, {
|
|
36
|
+
cwd,
|
|
37
|
+
shell: true,
|
|
38
|
+
encoding: "utf-8",
|
|
39
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
40
|
+
});
|
|
41
|
+
const durationMs = Date.now() - start;
|
|
42
|
+
const exitCode = proc.status ?? 1;
|
|
43
|
+
const combinedOutput = [proc.stdout, proc.stderr]
|
|
44
|
+
.filter((s) => typeof s === "string" && s.length > 0)
|
|
45
|
+
.join("\n")
|
|
46
|
+
.trim();
|
|
47
|
+
const passed = exitCode === 0;
|
|
48
|
+
results.push({
|
|
49
|
+
name: gate.name,
|
|
50
|
+
command: gate.command,
|
|
51
|
+
passed,
|
|
52
|
+
exitCode,
|
|
53
|
+
durationMs,
|
|
54
|
+
output: combinedOutput,
|
|
55
|
+
});
|
|
56
|
+
if (!passed && options.failFast) {
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
passed: results.every((r) => r.passed),
|
|
62
|
+
gates: results,
|
|
63
|
+
...(skipped ? { skipped } : {}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AAO;YACjB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;SAClC,CAAC,CAAC;QACH,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;QAClC,MAAM,cAAc,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;aAC9C,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;aACpD,IAAI,CAAC,IAAI,CAAC;aACV,IAAI,EAAE,CAAC;QAEV,MAAM,MAAM,GAAG,QAAQ,KAAK,CAAC,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM;YACN,QAAQ;YACR,UAAU;YACV,MAAM,EAAE,cAAc;SACvB,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YAChC,MAAM;QACR,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QACtC,KAAK,EAAE,OAAO;QACd,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./version.js";
|
|
2
|
+
export * from "./core/types.js";
|
|
3
|
+
export * from "./core/paths.js";
|
|
4
|
+
export * from "./core/config.js";
|
|
5
|
+
export * from "./core/glob.js";
|
|
6
|
+
export * from "./core/git.js";
|
|
7
|
+
export * from "./core/hotspots.js";
|
|
8
|
+
export * from "./core/rules.js";
|
|
9
|
+
export * from "./core/tasks.js";
|
|
10
|
+
export * from "./core/verify.js";
|
|
11
|
+
export * from "./core/init.js";
|
|
12
|
+
export * from "./core/mem.js";
|
|
13
|
+
export * from "./core/ablate.js";
|
|
14
|
+
export * from "./core/migrate.js";
|
|
15
|
+
export * from "./core/mcp.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from "./version.js";
|
|
2
|
+
export * from "./core/types.js";
|
|
3
|
+
export * from "./core/paths.js";
|
|
4
|
+
export * from "./core/config.js";
|
|
5
|
+
export * from "./core/glob.js";
|
|
6
|
+
export * from "./core/git.js";
|
|
7
|
+
export * from "./core/hotspots.js";
|
|
8
|
+
export * from "./core/rules.js";
|
|
9
|
+
export * from "./core/tasks.js";
|
|
10
|
+
export * from "./core/verify.js";
|
|
11
|
+
export * from "./core/init.js";
|
|
12
|
+
export * from "./core/mem.js";
|
|
13
|
+
export * from "./core/ablate.js";
|
|
14
|
+
export * from "./core/migrate.js";
|
|
15
|
+
export * from "./core/mcp.js";
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { VerifyGateConfig } from "../core/types.js";
|
|
2
|
+
export declare const AGENTS_START_MARKER = "<!-- KEEL:START -->";
|
|
3
|
+
export declare const AGENTS_END_MARKER = "<!-- KEEL:END -->";
|
|
4
|
+
export declare function renderAgentsBlock(): string;
|
|
5
|
+
export declare function renderDefaultConfig(gates?: VerifyGateConfig[]): string;
|
|
6
|
+
export declare function renderRulesIndex(): string;
|
|
7
|
+
export interface StandardSkillAsset {
|
|
8
|
+
dirName: string;
|
|
9
|
+
content: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function getStandardSkills(): StandardSkillAsset[];
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import YAML from "yaml";
|
|
2
|
+
export const AGENTS_START_MARKER = "<!-- KEEL:START -->";
|
|
3
|
+
export const AGENTS_END_MARKER = "<!-- KEEL:END -->";
|
|
4
|
+
export function renderAgentsBlock() {
|
|
5
|
+
return `${AGENTS_START_MARKER}
|
|
6
|
+
# Keel Engineering Context
|
|
7
|
+
|
|
8
|
+
This repository uses **Keel** for scoped engineering invariants, lightweight task contracts, cross-session memory, and deterministic verification.
|
|
9
|
+
|
|
10
|
+
- **Before editing non-trivial files**: pull matching invariants via \`keel rules match <files...>\` (or \`keel rules match --git\`).
|
|
11
|
+
- **Need past context or decisions?** Search cross-tool transcripts and repo specs via \`keel mem search "<query>"\`.
|
|
12
|
+
- **For multi-step or cross-session work**: persist scope and acceptance criteria in \`.keel/tasks/<id>/spec.md\` via \`keel task create "<title>"\`. Small edits do not need a task.
|
|
13
|
+
- **Before finishing**: run \`keel verify\` to execute deterministic project gates.
|
|
14
|
+
- **Execution is up to you**: Keel never prescribes whether to edit inline or dispatch native sub-agents/swarms — optimize for accuracy and speed, and satisfy the contracts.
|
|
15
|
+
- **After fixing a non-obvious bug or settling an architectural tradeoff**: distill the invariant into \`.keel/rules/\` (\`keel rules add\`) or promote it into an executable verification gate.
|
|
16
|
+
${AGENTS_END_MARKER}`;
|
|
17
|
+
}
|
|
18
|
+
export function renderDefaultConfig(gates = []) {
|
|
19
|
+
if (gates.length === 0) {
|
|
20
|
+
return `# Keel configuration
|
|
21
|
+
version: 1
|
|
22
|
+
|
|
23
|
+
verify:
|
|
24
|
+
gates:
|
|
25
|
+
# Add deterministic project checks here, e.g.:
|
|
26
|
+
# - name: typecheck
|
|
27
|
+
# command: pnpm typecheck
|
|
28
|
+
# - name: test
|
|
29
|
+
# command: pnpm test
|
|
30
|
+
[]
|
|
31
|
+
|
|
32
|
+
memory:
|
|
33
|
+
sources: []
|
|
34
|
+
`;
|
|
35
|
+
}
|
|
36
|
+
const doc = {
|
|
37
|
+
version: 1,
|
|
38
|
+
verify: {
|
|
39
|
+
gates: gates.map((g) => ({
|
|
40
|
+
name: g.name,
|
|
41
|
+
command: g.command,
|
|
42
|
+
...(g.cwd ? { cwd: g.cwd } : {}),
|
|
43
|
+
...(g.paths ? { paths: g.paths } : {}),
|
|
44
|
+
})),
|
|
45
|
+
},
|
|
46
|
+
memory: {
|
|
47
|
+
sources: [],
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
return `# Keel configuration\n${YAML.stringify(doc)}`;
|
|
51
|
+
}
|
|
52
|
+
export function renderRulesIndex() {
|
|
53
|
+
return `# Engineering Rules & Invariants
|
|
54
|
+
|
|
55
|
+
Keep this directory high-signal.
|
|
56
|
+
|
|
57
|
+
**What belongs here**
|
|
58
|
+
- Non-obvious architectural invariants (\`severity: invariant\`)
|
|
59
|
+
- Historical footguns and negative constraints ("Don't do X because Y")
|
|
60
|
+
- Architecture Decision Records (\`severity: adr\`)
|
|
61
|
+
|
|
62
|
+
**What does NOT belong here**
|
|
63
|
+
- Conventions obvious from reading two nearby files
|
|
64
|
+
- Rules that can be enforced automatically by a linter, type-checker, or test (add those to \`.keel/config.yaml\` under \`verify.gates\` instead)
|
|
65
|
+
|
|
66
|
+
## Rule File Format
|
|
67
|
+
|
|
68
|
+
\`\`\`markdown
|
|
69
|
+
---
|
|
70
|
+
id: short-kebab-id
|
|
71
|
+
summary: One-line summary shown by \`keel rules match\`
|
|
72
|
+
severity: invariant # invariant | guideline | adr
|
|
73
|
+
paths:
|
|
74
|
+
- src/module/**
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
Explain the invariant and *why* it exists.
|
|
78
|
+
\`\`\`
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
export function getStandardSkills() {
|
|
82
|
+
return [
|
|
83
|
+
{
|
|
84
|
+
dirName: "keel-plan",
|
|
85
|
+
content: `---
|
|
86
|
+
name: keel-plan
|
|
87
|
+
description: Align requirements and persist a concise living task spec in .keel/tasks/ when work is multi-step, ambiguous, or spans sessions.
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
# Keel Plan
|
|
91
|
+
|
|
92
|
+
Use this skill when a request is ambiguous, multi-step, or likely to span sessions. Skip it for trivial edits.
|
|
93
|
+
|
|
94
|
+
1. Explore the relevant code first instead of asking questions the codebase already answers.
|
|
95
|
+
2. Check existing invariants with \`keel rules match <target-paths>\` and check prior decisions with \`keel mem search "<topic>"\`.
|
|
96
|
+
3. Create a task when persistence helps: \`keel task create "<title>"\`.
|
|
97
|
+
4. Maintain a single concise \`spec.md\` covering **Goal**, **Non-Goals**, **Acceptance Criteria**, and key **Decisions**. Put deeper technical notes in \`research/\` if needed.
|
|
98
|
+
5. Execution strategy (inline vs. native sub-agents/swarms) is up to the host harness once requirements are clear.
|
|
99
|
+
`,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
dirName: "keel-verify",
|
|
103
|
+
content: `---
|
|
104
|
+
name: keel-verify
|
|
105
|
+
description: Verify changes against deterministic project gates, matched Keel invariants, and task acceptance criteria before finishing.
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
# Keel Verify
|
|
109
|
+
|
|
110
|
+
Run this before declaring work complete:
|
|
111
|
+
|
|
112
|
+
1. Execute \`keel verify\` to run all configured deterministic gates (typecheck, lint, tests, invariant checks).
|
|
113
|
+
2. Run \`keel rules match --git\` and confirm the diff respects every matched invariant.
|
|
114
|
+
3. If working on an active task under \`.keel/tasks/\`, verify every acceptance criterion in \`spec.md\`.
|
|
115
|
+
4. For high-risk or cross-module changes, prefer a fresh-context review of the diff to catch blind spots.
|
|
116
|
+
`,
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
dirName: "keel-distill",
|
|
120
|
+
content: `---
|
|
121
|
+
name: keel-distill
|
|
122
|
+
description: Distill non-obvious engineering lessons, bug root causes, or architectural decisions into executable gates or concise .keel/rules/ entries.
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
# Keel Distill
|
|
126
|
+
|
|
127
|
+
Use this after solving a tricky bug, finishing an architectural change, or resolving a recurring review comment.
|
|
128
|
+
|
|
129
|
+
1. Ask first: **Can this be enforced deterministically** (a unit test, invariant test, lint rule, or schema check)? If yes, write the check and ensure it runs under \`keel verify\`.
|
|
130
|
+
2. Otherwise, if the insight cannot be inferred just from reading the code, add or update a concise scoped rule via \`keel rules add <id> --summary "..." --paths "..."\` and explain **Why**.
|
|
131
|
+
3. Keep rules brief and delete obsolete ones — stale rules hurt agent performance.
|
|
132
|
+
`,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
dirName: "keel-mem",
|
|
136
|
+
content: `---
|
|
137
|
+
name: keel-mem
|
|
138
|
+
description: Recall past decisions, debugging trails, and rationale across local AI coding sessions and repository specs using keel mem.
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
# Keel Mem
|
|
142
|
+
|
|
143
|
+
Use this whenever someone asks "why did we do X?", "how did we fix this before?", or before refactoring unfamiliar code.
|
|
144
|
+
|
|
145
|
+
1. Run \`keel mem search "<keywords>"\` to search across local AI transcripts and \`.keel/\` task/rule artifacts.
|
|
146
|
+
2. Inspect full context for a relevant session with \`keel mem show <session-id>\`.
|
|
147
|
+
3. Quote concrete rationale rather than guessing; if the decision matters long-term, distill it into \`.keel/rules/\`.
|
|
148
|
+
`,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
dirName: "keel-migrate",
|
|
152
|
+
content: `---
|
|
153
|
+
name: keel-migrate
|
|
154
|
+
description: Migrate a repository from Trellis, .cursorrules, CLAUDE.md, or other AI workflow setups to Keel by distilling high-signal rules, configuring gates, and cleaning up conflicting hooks.
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
# Keel Migrate
|
|
158
|
+
|
|
159
|
+
Use this skill once when moving an existing repository from another AI coding setup (Trellis, \`.cursorrules\`, \`CLAUDE.md\`, Copilot instructions, Spec-Kit, BMAD) to Keel.
|
|
160
|
+
|
|
161
|
+
## Steps
|
|
162
|
+
|
|
163
|
+
1. Run \`keel init\` if \`.keel/\` does not exist yet.
|
|
164
|
+
2. Run \`keel migrate scan --json\` and \`keel migrate plan --json\` to inventory every legacy file, active hook conflict, candidate gate, and archive directory.
|
|
165
|
+
3. Configure \`.keel/config.yaml\`:
|
|
166
|
+
- Add real project checks under \`verify.gates\` (use \`paths\` on module-specific gates in monorepos so \`keel verify --git\` stays fast).
|
|
167
|
+
- Add existing ADR or archive directories (such as \`docs/adr\` or \`.trellis/tasks/archive\`) to \`memory.sources\` instead of copying them.
|
|
168
|
+
4. Distill legacy specs 10:1 into \`.keel/rules/\`:
|
|
169
|
+
- **Drop** generic coding style guides, directory overviews, boilerplate checklists, and old sub-agent/workflow instructions.
|
|
170
|
+
- **Promote to gates** anything that can be checked by a command or test.
|
|
171
|
+
- **Keep as scoped rules** (\`keel rules add <id> --summary "..." --paths "..."\`) only things an engineer or model cannot infer from reading nearby code: negative constraints ("never do X because Y"), historical bug traps, external system quirks, and tie-breakers where legacy and new patterns coexist. Keep each rule concise (~10-20 lines).
|
|
172
|
+
5. If there is an active in-progress task in the old tool, consolidate its goal, non-goals, and acceptance criteria into one \`spec.md\` with \`keel task create\`. Leave archived tasks untouched.
|
|
173
|
+
6. Run \`keel rules check --stale\` and \`keel verify\` to confirm the new setup passes cleanly.
|
|
174
|
+
7. Preview conflict removal with \`keel migrate cleanup --dry-run\`. Ask the user to confirm before running \`keel migrate cleanup\` (which backs up removed files outside the repo and can be undone with \`keel migrate rollback\`).
|
|
175
|
+
`,
|
|
176
|
+
},
|
|
177
|
+
];
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=assets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../../src/templates/assets.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AACzD,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAErD,MAAM,UAAU,iBAAiB;IAC/B,OAAO,GAAG,mBAAmB;;;;;;;;;;;EAW7B,iBAAiB,EAAE,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,QAA4B,EAAE;IAChE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO;;;;;;;;;;;;;;CAcV,CAAC;IACA,CAAC;IAED,MAAM,GAAG,GAAG;QACV,OAAO,EAAE,CAAC;QACV,MAAM,EAAE;YACN,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACvB,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAChC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACvC,CAAC,CAAC;SACJ;QACD,MAAM,EAAE;YACN,OAAO,EAAE,EAAE;SACZ;KACF,CAAC;IAEF,OAAO,yBAAyB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BR,CAAC;AACF,CAAC;AAOD,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL;YACE,OAAO,EAAE,WAAW;YACpB,OAAO,EAAE;;;;;;;;;;;;;;CAcd;SACI;QACD;YACE,OAAO,EAAE,aAAa;YACtB,OAAO,EAAE;;;;;;;;;;;;;CAad;SACI;QACD;YACE,OAAO,EAAE,cAAc;YACvB,OAAO,EAAE;;;;;;;;;;;;CAYd;SACI;QACD;YACE,OAAO,EAAE,UAAU;YACnB,OAAO,EAAE;;;;;;;;;;;;CAYd;SACI;QACD;YACE,OAAO,EAAE,cAAc;YACvB,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;CAuBd;SACI;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const KEEL_VERSION = "1.1.0";
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC"}
|