recall-os 0.1.1 → 0.2.1
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/README.md +43 -20
- package/dist/cli.js +1791 -792
- package/dist/cli.js.map +1 -1
- package/dist/index.js +1791 -792
- package/dist/index.js.map +1 -1
- package/examples/generated-flutter/docs/20-security/SECURITY_MODEL.md +25 -4
- package/examples/generated-flutter/docs/20-security/THREAT_MODEL.md +35 -3
- package/examples/generated-generic/docs/20-security/SECURITY_MODEL.md +25 -4
- package/examples/generated-generic/docs/20-security/THREAT_MODEL.md +35 -3
- package/examples/generated-ios-swift/docs/20-security/SECURITY_MODEL.md +25 -4
- package/examples/generated-ios-swift/docs/20-security/THREAT_MODEL.md +35 -3
- package/examples/generated-kotlin-android/docs/20-security/SECURITY_MODEL.md +25 -4
- package/examples/generated-kotlin-android/docs/20-security/THREAT_MODEL.md +35 -3
- package/examples/generated-laravel-api/.recall/config.json +17 -0
- package/examples/generated-laravel-api/.recall/hooks/pre-commit +9 -0
- package/examples/generated-laravel-api/AGENTS.md +15 -0
- package/examples/generated-laravel-api/CLAUDE.md +9 -0
- package/examples/generated-laravel-api/README.md +11 -0
- package/examples/generated-laravel-api/docs/00-product/BRD.md +9 -0
- package/examples/generated-laravel-api/docs/00-product/PRD.md +13 -0
- package/examples/generated-laravel-api/docs/10-architecture/ARCHITECTURE.md +11 -0
- package/examples/generated-laravel-api/docs/10-architecture/FILE_WRITE_POLICY.md +8 -0
- package/examples/generated-laravel-api/docs/10-architecture/MEMORY_ENGINE.md +16 -0
- package/examples/generated-laravel-api/docs/20-security/SECURITY_MODEL.md +32 -0
- package/examples/generated-laravel-api/docs/20-security/THREAT_MODEL.md +39 -0
- package/examples/generated-laravel-api/docs/30-modules/README.md +17 -0
- package/examples/generated-laravel-api/docs/40-features/README.md +22 -0
- package/examples/generated-laravel-api/docs/50-quality/QUALITY_GATES.md +11 -0
- package/examples/generated-laravel-api/docs/50-quality/TESTING_STRATEGY.md +5 -0
- package/examples/generated-laravel-api/docs/60-engineering/AI_AGENT_RULES.md +6 -0
- package/examples/generated-laravel-api/docs/60-engineering/ENGINEERING_STANDARDS.md +11 -0
- package/examples/generated-laravel-api/docs/adrs/README.md +9 -0
- package/examples/generated-laravel-api/docs/adrs/proposed/ADR-PROPOSED-laravel-api-api-design-rest.md +31 -0
- package/examples/generated-laravel-api/docs/adrs/proposed/ADR-PROPOSED-laravel-api-application-structure.md +30 -0
- package/examples/generated-laravel-api/docs/adrs/proposed/ADR-PROPOSED-laravel-api-auth-sanctum.md +30 -0
- package/examples/generated-laravel-api/docs/adrs/proposed/ADR-PROPOSED-laravel-api-database-eloquent.md +31 -0
- package/examples/generated-laravel-api/docs/adrs/proposed/ADR-PROPOSED-laravel-api-framework.md +29 -0
- package/examples/generated-laravel-api/docs/adrs/proposed/ADR-PROPOSED-laravel-api-queues-horizon.md +29 -0
- package/examples/generated-laravel-api/docs/adrs/proposed/ADR-PROPOSED-laravel-api-testing-pest.md +30 -0
- package/examples/generated-laravel-api/docs/adrs/proposed/ADR-PROPOSED-laravel-api-validation-authorization.md +30 -0
- package/examples/generated-laravel-api/docs/ai/AI_AGENTS_SKILLS_MCP_STRATEGY.md +7 -0
- package/examples/generated-laravel-api/docs/ai/MCP_STRATEGY.md +6 -0
- package/examples/generated-laravel-api/docs/ai/RECALL_COMMANDS.md +133 -0
- package/examples/generated-laravel-api/docs/ai/presets/laravel-api-guidance.md +62 -0
- package/examples/generated-laravel-react/.recall/config.json +17 -0
- package/examples/generated-laravel-react/.recall/hooks/pre-commit +9 -0
- package/examples/generated-laravel-react/AGENTS.md +15 -0
- package/examples/generated-laravel-react/CLAUDE.md +9 -0
- package/examples/generated-laravel-react/README.md +11 -0
- package/examples/generated-laravel-react/docs/00-product/BRD.md +9 -0
- package/examples/generated-laravel-react/docs/00-product/PRD.md +13 -0
- package/examples/generated-laravel-react/docs/10-architecture/ARCHITECTURE.md +11 -0
- package/examples/generated-laravel-react/docs/10-architecture/FILE_WRITE_POLICY.md +8 -0
- package/examples/generated-laravel-react/docs/10-architecture/MEMORY_ENGINE.md +16 -0
- package/examples/generated-laravel-react/docs/20-security/SECURITY_MODEL.md +32 -0
- package/examples/generated-laravel-react/docs/20-security/THREAT_MODEL.md +39 -0
- package/examples/generated-laravel-react/docs/30-modules/README.md +17 -0
- package/examples/generated-laravel-react/docs/40-features/README.md +22 -0
- package/examples/generated-laravel-react/docs/50-quality/QUALITY_GATES.md +11 -0
- package/examples/generated-laravel-react/docs/50-quality/TESTING_STRATEGY.md +5 -0
- package/examples/generated-laravel-react/docs/60-engineering/AI_AGENT_RULES.md +6 -0
- package/examples/generated-laravel-react/docs/60-engineering/ENGINEERING_STANDARDS.md +11 -0
- package/examples/generated-laravel-react/docs/adrs/README.md +9 -0
- package/examples/generated-laravel-react/docs/adrs/proposed/ADR-PROPOSED-laravel-react-application-structure.md +30 -0
- package/examples/generated-laravel-react/docs/adrs/proposed/ADR-PROPOSED-laravel-react-auth-sanctum.md +31 -0
- package/examples/generated-laravel-react/docs/adrs/proposed/ADR-PROPOSED-laravel-react-database-eloquent.md +31 -0
- package/examples/generated-laravel-react/docs/adrs/proposed/ADR-PROPOSED-laravel-react-framework.md +29 -0
- package/examples/generated-laravel-react/docs/adrs/proposed/ADR-PROPOSED-laravel-react-frontend-inertia-react.md +31 -0
- package/examples/generated-laravel-react/docs/adrs/proposed/ADR-PROPOSED-laravel-react-queues-horizon.md +29 -0
- package/examples/generated-laravel-react/docs/adrs/proposed/ADR-PROPOSED-laravel-react-testing-pest.md +30 -0
- package/examples/generated-laravel-react/docs/adrs/proposed/ADR-PROPOSED-laravel-react-validation-authorization.md +30 -0
- package/examples/generated-laravel-react/docs/ai/AI_AGENTS_SKILLS_MCP_STRATEGY.md +7 -0
- package/examples/generated-laravel-react/docs/ai/MCP_STRATEGY.md +6 -0
- package/examples/generated-laravel-react/docs/ai/RECALL_COMMANDS.md +133 -0
- package/examples/generated-laravel-react/docs/ai/presets/laravel-react-guidance.md +64 -0
- package/examples/generated-laravel-vue/.recall/config.json +17 -0
- package/examples/generated-laravel-vue/.recall/hooks/pre-commit +9 -0
- package/examples/generated-laravel-vue/AGENTS.md +15 -0
- package/examples/generated-laravel-vue/CLAUDE.md +9 -0
- package/examples/generated-laravel-vue/README.md +11 -0
- package/examples/generated-laravel-vue/docs/00-product/BRD.md +9 -0
- package/examples/generated-laravel-vue/docs/00-product/PRD.md +13 -0
- package/examples/generated-laravel-vue/docs/10-architecture/ARCHITECTURE.md +11 -0
- package/examples/generated-laravel-vue/docs/10-architecture/FILE_WRITE_POLICY.md +8 -0
- package/examples/generated-laravel-vue/docs/10-architecture/MEMORY_ENGINE.md +16 -0
- package/examples/generated-laravel-vue/docs/20-security/SECURITY_MODEL.md +32 -0
- package/examples/generated-laravel-vue/docs/20-security/THREAT_MODEL.md +39 -0
- package/examples/generated-laravel-vue/docs/30-modules/README.md +17 -0
- package/examples/generated-laravel-vue/docs/40-features/README.md +22 -0
- package/examples/generated-laravel-vue/docs/50-quality/QUALITY_GATES.md +11 -0
- package/examples/generated-laravel-vue/docs/50-quality/TESTING_STRATEGY.md +5 -0
- package/examples/generated-laravel-vue/docs/60-engineering/AI_AGENT_RULES.md +6 -0
- package/examples/generated-laravel-vue/docs/60-engineering/ENGINEERING_STANDARDS.md +11 -0
- package/examples/generated-laravel-vue/docs/adrs/README.md +9 -0
- package/examples/generated-laravel-vue/docs/adrs/proposed/ADR-PROPOSED-laravel-vue-application-structure.md +30 -0
- package/examples/generated-laravel-vue/docs/adrs/proposed/ADR-PROPOSED-laravel-vue-auth-sanctum.md +31 -0
- package/examples/generated-laravel-vue/docs/adrs/proposed/ADR-PROPOSED-laravel-vue-database-eloquent.md +31 -0
- package/examples/generated-laravel-vue/docs/adrs/proposed/ADR-PROPOSED-laravel-vue-framework.md +29 -0
- package/examples/generated-laravel-vue/docs/adrs/proposed/ADR-PROPOSED-laravel-vue-frontend-inertia-vue.md +31 -0
- package/examples/generated-laravel-vue/docs/adrs/proposed/ADR-PROPOSED-laravel-vue-queues-horizon.md +29 -0
- package/examples/generated-laravel-vue/docs/adrs/proposed/ADR-PROPOSED-laravel-vue-testing-pest.md +30 -0
- package/examples/generated-laravel-vue/docs/adrs/proposed/ADR-PROPOSED-laravel-vue-validation-authorization.md +30 -0
- package/examples/generated-laravel-vue/docs/ai/AI_AGENTS_SKILLS_MCP_STRATEGY.md +7 -0
- package/examples/generated-laravel-vue/docs/ai/MCP_STRATEGY.md +6 -0
- package/examples/generated-laravel-vue/docs/ai/RECALL_COMMANDS.md +133 -0
- package/examples/generated-laravel-vue/docs/ai/presets/laravel-vue-guidance.md +64 -0
- package/examples/generated-nextjs/docs/20-security/SECURITY_MODEL.md +25 -4
- package/examples/generated-nextjs/docs/20-security/THREAT_MODEL.md +35 -3
- package/examples/generated-python-fastapi/docs/20-security/SECURITY_MODEL.md +25 -4
- package/examples/generated-python-fastapi/docs/20-security/THREAT_MODEL.md +35 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -134,8 +134,8 @@ function parseConfig(value) {
|
|
|
134
134
|
if (!result.success) {
|
|
135
135
|
throw new ConfigValidationError(
|
|
136
136
|
result.error.issues.map((issue) => {
|
|
137
|
-
const
|
|
138
|
-
return `${
|
|
137
|
+
const path17 = issue.path.length > 0 ? `${issue.path.join(".")}: ` : "";
|
|
138
|
+
return `${path17}${issue.message}`;
|
|
139
139
|
})
|
|
140
140
|
);
|
|
141
141
|
}
|
|
@@ -1230,106 +1230,31 @@ function createDefaultConfig(overrides = {}) {
|
|
|
1230
1230
|
});
|
|
1231
1231
|
}
|
|
1232
1232
|
|
|
1233
|
-
// src/core/adopt/generate-adoption.ts
|
|
1234
|
-
var ADOPTION_REPORT_PATH = "docs/adopt/ADOPTION_REPORT.md";
|
|
1235
|
-
function generateAdoptionFiles(options) {
|
|
1236
|
-
const files = [
|
|
1237
|
-
{
|
|
1238
|
-
path: ADOPTION_REPORT_PATH,
|
|
1239
|
-
content: renderReport(options.adrDir, options.signals)
|
|
1240
|
-
}
|
|
1241
|
-
];
|
|
1242
|
-
for (const framework of options.signals.frameworks) {
|
|
1243
|
-
files.push({
|
|
1244
|
-
path: `${options.adrDir}/proposed/ADR-PROPOSED-adopt-${frameworkSlug(framework)}.md`,
|
|
1245
|
-
content: renderProposedAdr(framework)
|
|
1246
|
-
});
|
|
1247
|
-
}
|
|
1248
|
-
return files;
|
|
1249
|
-
}
|
|
1250
|
-
function renderReport(adrDir, signals) {
|
|
1251
|
-
return `# Adoption Report
|
|
1252
|
-
|
|
1253
|
-
## Status
|
|
1254
|
-
|
|
1255
|
-
Proposed. Everything below is inferred from this repository and requires human review. Nothing here
|
|
1256
|
-
is accepted repository memory until you accept it.
|
|
1257
|
-
|
|
1258
|
-
## Detected Signals
|
|
1259
|
-
|
|
1260
|
-
- Languages: ${formatList(signals.languages)}
|
|
1261
|
-
- Package manager: ${signals.packageManager ?? "none detected"}
|
|
1262
|
-
- Frameworks: ${formatList(signals.frameworks)}
|
|
1263
|
-
- Tests present: ${formatBool(signals.hasTests)}
|
|
1264
|
-
- README present: ${formatBool(signals.hasReadme)}
|
|
1265
|
-
- Docs folder present: ${formatBool(signals.hasDocs)}
|
|
1266
|
-
|
|
1267
|
-
## Proposed Decisions
|
|
1268
|
-
|
|
1269
|
-
${renderProposedDecisions(adrDir, signals)}
|
|
1270
|
-
|
|
1271
|
-
## Review Checklist
|
|
1272
|
-
|
|
1273
|
-
- [ ] Confirm the detected languages and package manager.
|
|
1274
|
-
- [ ] Accept or reject each proposed framework ADR under \`${adrDir}/proposed/\`.
|
|
1275
|
-
- [ ] Run \`recall init\` to establish neutral repository memory if it does not exist yet.
|
|
1276
|
-
- [ ] Record any decision you accept with \`recall adr create\` or by accepting the proposed ADR.
|
|
1277
|
-
|
|
1278
|
-
## Notes
|
|
1279
|
-
|
|
1280
|
-
This report was produced by \`recall adopt\` through read-only inspection of manifest and marker
|
|
1281
|
-
files. No repository code was executed and no decision was accepted automatically.
|
|
1282
|
-
`;
|
|
1283
|
-
}
|
|
1284
|
-
function renderProposedDecisions(adrDir, signals) {
|
|
1285
|
-
if (signals.frameworks.length === 0) {
|
|
1286
|
-
return "- No framework decisions were inferred. Add decisions with `recall adr create` as needed.";
|
|
1287
|
-
}
|
|
1288
|
-
return signals.frameworks.map(
|
|
1289
|
-
(framework) => `- Proposed: record **${framework}** as an architecture decision (see \`${adrDir}/proposed/ADR-PROPOSED-adopt-${frameworkSlug(framework)}.md\`). Requires review.`
|
|
1290
|
-
).join("\n");
|
|
1291
|
-
}
|
|
1292
|
-
function renderProposedAdr(framework) {
|
|
1293
|
-
return `# Proposed ADR: Use ${framework}
|
|
1294
|
-
|
|
1295
|
-
## Status
|
|
1296
|
-
|
|
1297
|
-
Proposed
|
|
1298
|
-
|
|
1299
|
-
## Context
|
|
1300
|
-
|
|
1301
|
-
\`recall adopt\` detected ${framework} in this repository through read-only inspection.
|
|
1302
|
-
|
|
1303
|
-
## Decision
|
|
1304
|
-
|
|
1305
|
-
Consider recording ${framework} as an accepted architecture decision. This is proposed by adoption
|
|
1306
|
-
and is not accepted until a human reviews and accepts it.
|
|
1307
|
-
|
|
1308
|
-
## Alternatives Considered
|
|
1309
|
-
|
|
1310
|
-
- Record a different framework.
|
|
1311
|
-
- Leave the decision unrecorded for now.
|
|
1312
|
-
|
|
1313
|
-
## Consequences
|
|
1314
|
-
|
|
1315
|
-
- Captures a framework already in use as reviewable repository memory.
|
|
1316
|
-
- Requires explicit human acceptance before it becomes repository truth.
|
|
1317
|
-
`;
|
|
1318
|
-
}
|
|
1319
|
-
function frameworkSlug(framework) {
|
|
1320
|
-
return framework.toLowerCase().replace(/\./gu, "").replace(/[^a-z0-9]+/gu, "-").replace(/^-+|-+$/gu, "");
|
|
1321
|
-
}
|
|
1322
|
-
function formatList(values) {
|
|
1323
|
-
return values.length > 0 ? values.join(", ") : "none detected";
|
|
1324
|
-
}
|
|
1325
|
-
function formatBool(value) {
|
|
1326
|
-
return value ? "yes" : "no";
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
1233
|
// src/core/adopt/inspect-repo.ts
|
|
1330
1234
|
import { existsSync as existsSync3 } from "fs";
|
|
1331
|
-
import { readFile as readFile3 } from "fs/promises";
|
|
1235
|
+
import { readFile as readFile3, readdir as readdir4 } from "fs/promises";
|
|
1332
1236
|
import path6 from "path";
|
|
1237
|
+
var FRAMEWORK_SOURCES = {
|
|
1238
|
+
"Next.js": "package.json",
|
|
1239
|
+
React: "package.json",
|
|
1240
|
+
NestJS: "package.json",
|
|
1241
|
+
Express: "package.json",
|
|
1242
|
+
FastAPI: "pyproject.toml / requirements.txt",
|
|
1243
|
+
Flask: "pyproject.toml / requirements.txt",
|
|
1244
|
+
Django: "pyproject.toml / requirements.txt",
|
|
1245
|
+
Gin: "go.mod",
|
|
1246
|
+
Echo: "go.mod",
|
|
1247
|
+
Fiber: "go.mod",
|
|
1248
|
+
Chi: "go.mod",
|
|
1249
|
+
"Spring Boot": "pom.xml / build.gradle",
|
|
1250
|
+
"Actix Web": "Cargo.toml",
|
|
1251
|
+
Axum: "Cargo.toml",
|
|
1252
|
+
Rocket: "Cargo.toml",
|
|
1253
|
+
Laravel: "composer.json",
|
|
1254
|
+
Symfony: "composer.json",
|
|
1255
|
+
"Ruby on Rails": "Gemfile",
|
|
1256
|
+
Flutter: "pubspec.yaml"
|
|
1257
|
+
};
|
|
1333
1258
|
async function inspectRepo(rootDir) {
|
|
1334
1259
|
const has = (relativePath) => existsSync3(path6.join(rootDir, relativePath));
|
|
1335
1260
|
const languages = /* @__PURE__ */ new Set();
|
|
@@ -1363,6 +1288,22 @@ async function inspectRepo(rootDir) {
|
|
|
1363
1288
|
languages.add("Dart");
|
|
1364
1289
|
frameworks.add("Flutter");
|
|
1365
1290
|
}
|
|
1291
|
+
if (has("composer.json")) {
|
|
1292
|
+
languages.add("PHP");
|
|
1293
|
+
const composer = (await readText(rootDir, "composer.json")).toLowerCase();
|
|
1294
|
+
if (composer.includes("laravel/framework")) {
|
|
1295
|
+
frameworks.add("Laravel");
|
|
1296
|
+
} else if (composer.includes("symfony/")) {
|
|
1297
|
+
frameworks.add("Symfony");
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
if (has("Gemfile")) {
|
|
1301
|
+
languages.add("Ruby");
|
|
1302
|
+
const gemfile = (await readText(rootDir, "Gemfile")).toLowerCase();
|
|
1303
|
+
if (gemfile.includes("rails")) {
|
|
1304
|
+
frameworks.add("Ruby on Rails");
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1366
1307
|
const deps = collectDependencies(pkg);
|
|
1367
1308
|
if ("next" in deps) {
|
|
1368
1309
|
frameworks.add("Next.js");
|
|
@@ -1382,25 +1323,173 @@ async function inspectRepo(rootDir) {
|
|
|
1382
1323
|
} else if (python.includes("django")) {
|
|
1383
1324
|
frameworks.add("Django");
|
|
1384
1325
|
}
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1326
|
+
if (has("go.mod")) {
|
|
1327
|
+
const goModules = `${await readText(rootDir, "go.mod")}${await readText(rootDir, "go.sum")}`;
|
|
1328
|
+
if (goModules.includes("gin-gonic/gin")) {
|
|
1329
|
+
frameworks.add("Gin");
|
|
1330
|
+
} else if (goModules.includes("labstack/echo")) {
|
|
1331
|
+
frameworks.add("Echo");
|
|
1332
|
+
} else if (goModules.includes("gofiber/fiber")) {
|
|
1333
|
+
frameworks.add("Fiber");
|
|
1334
|
+
} else if (goModules.includes("go-chi/chi")) {
|
|
1335
|
+
frameworks.add("Chi");
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
const jvmManifest = `${await readText(rootDir, "pom.xml")}${await readText(rootDir, "build.gradle")}${await readText(rootDir, "build.gradle.kts")}`.toLowerCase();
|
|
1339
|
+
if (jvmManifest.includes("spring-boot") || jvmManifest.includes("springframework")) {
|
|
1340
|
+
frameworks.add("Spring Boot");
|
|
1341
|
+
}
|
|
1342
|
+
if (has("Cargo.toml")) {
|
|
1343
|
+
const cargo = (await readText(rootDir, "Cargo.toml")).toLowerCase();
|
|
1344
|
+
if (cargo.includes("actix-web")) {
|
|
1345
|
+
frameworks.add("Actix Web");
|
|
1346
|
+
} else if (cargo.includes("axum")) {
|
|
1347
|
+
frameworks.add("Axum");
|
|
1348
|
+
} else if (cargo.includes("rocket")) {
|
|
1349
|
+
frameworks.add("Rocket");
|
|
1350
|
+
}
|
|
1392
1351
|
}
|
|
1352
|
+
const [packageManager, packageManagerSource] = detectPackageManager(has);
|
|
1393
1353
|
const scripts = pkg !== null && isRecord(pkg.scripts) ? pkg.scripts : {};
|
|
1394
|
-
const
|
|
1354
|
+
const testsEvidence = await detectTestsEvidence(rootDir, has, "test" in scripts, python);
|
|
1395
1355
|
return {
|
|
1396
1356
|
languages: [...languages],
|
|
1397
1357
|
packageManager,
|
|
1358
|
+
packageManagerSource,
|
|
1398
1359
|
frameworks: [...frameworks],
|
|
1399
|
-
hasTests,
|
|
1360
|
+
hasTests: testsEvidence !== null,
|
|
1361
|
+
testsEvidence,
|
|
1400
1362
|
hasReadme: has("README.md") || has("README"),
|
|
1401
1363
|
hasDocs: has("docs")
|
|
1402
1364
|
};
|
|
1403
1365
|
}
|
|
1366
|
+
function summarizeSignals(signals) {
|
|
1367
|
+
const lines = [];
|
|
1368
|
+
lines.push(`- Languages: ${formatList(signals.languages)}`);
|
|
1369
|
+
lines.push(
|
|
1370
|
+
signals.packageManager === null ? "- Package manager: none detected" : `- Package manager: ${signals.packageManager}${signals.packageManagerSource === null ? "" : ` (from \`${signals.packageManagerSource}\`)`}`
|
|
1371
|
+
);
|
|
1372
|
+
if (signals.frameworks.length === 0) {
|
|
1373
|
+
lines.push("- Frameworks: none detected");
|
|
1374
|
+
} else {
|
|
1375
|
+
const withSource = signals.frameworks.map((framework) => {
|
|
1376
|
+
const source = FRAMEWORK_SOURCES[framework];
|
|
1377
|
+
return source === void 0 ? framework : `${framework} (from \`${source}\`)`;
|
|
1378
|
+
});
|
|
1379
|
+
lines.push(`- Frameworks: ${withSource.join(", ")}`);
|
|
1380
|
+
}
|
|
1381
|
+
lines.push(
|
|
1382
|
+
signals.testsEvidence === null ? "- Tests: none detected \u2014 if tests exist, point Recall at them by correcting this report" : `- Tests: detected via ${signals.testsEvidence}`
|
|
1383
|
+
);
|
|
1384
|
+
lines.push(`- README present: ${signals.hasReadme ? "yes" : "no"}`);
|
|
1385
|
+
lines.push(`- Docs folder present: ${signals.hasDocs ? "yes" : "no"}`);
|
|
1386
|
+
return lines;
|
|
1387
|
+
}
|
|
1388
|
+
function formatList(values) {
|
|
1389
|
+
return values.length === 0 ? "none detected" : values.join(", ");
|
|
1390
|
+
}
|
|
1391
|
+
function detectPackageManager(has) {
|
|
1392
|
+
const candidates = [
|
|
1393
|
+
[has("go.mod"), "Go modules", "go.mod"],
|
|
1394
|
+
[has("Cargo.toml"), "Cargo", "Cargo.toml"],
|
|
1395
|
+
[has("pom.xml"), "Maven", "pom.xml"],
|
|
1396
|
+
[has("build.gradle"), "Gradle", "build.gradle"],
|
|
1397
|
+
[has("build.gradle.kts"), "Gradle", "build.gradle.kts"],
|
|
1398
|
+
[has("composer.json"), "Composer", "composer.json"],
|
|
1399
|
+
[has("Gemfile"), "Bundler", "Gemfile"],
|
|
1400
|
+
[has("Package.swift"), "Swift Package Manager", "Package.swift"],
|
|
1401
|
+
[has("pubspec.yaml"), "pub", "pubspec.yaml"],
|
|
1402
|
+
[has("uv.lock"), "uv", "uv.lock"],
|
|
1403
|
+
[has("poetry.lock"), "Poetry", "poetry.lock"],
|
|
1404
|
+
[has("requirements.txt"), "pip", "requirements.txt"],
|
|
1405
|
+
[has("pyproject.toml"), "pip", "pyproject.toml"],
|
|
1406
|
+
[has("pnpm-lock.yaml"), "pnpm", "pnpm-lock.yaml"],
|
|
1407
|
+
[has("yarn.lock"), "yarn", "yarn.lock"],
|
|
1408
|
+
[has("package-lock.json"), "npm", "package-lock.json"],
|
|
1409
|
+
[has("package.json"), "npm", "package.json"]
|
|
1410
|
+
];
|
|
1411
|
+
for (const [present, name, source] of candidates) {
|
|
1412
|
+
if (present) {
|
|
1413
|
+
return [name, source];
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
return [null, null];
|
|
1417
|
+
}
|
|
1418
|
+
async function detectTestsEvidence(rootDir, has, hasTestScript, pythonText) {
|
|
1419
|
+
if (has("tests")) {
|
|
1420
|
+
return "`tests/` directory";
|
|
1421
|
+
}
|
|
1422
|
+
if (has("test")) {
|
|
1423
|
+
return "`test/` directory";
|
|
1424
|
+
}
|
|
1425
|
+
if (has("__tests__")) {
|
|
1426
|
+
return "`__tests__/` directory";
|
|
1427
|
+
}
|
|
1428
|
+
if (has("pytest.ini") || pythonText.includes("pytest")) {
|
|
1429
|
+
return "pytest configuration";
|
|
1430
|
+
}
|
|
1431
|
+
if (has("phpunit.xml") || has("phpunit.xml.dist")) {
|
|
1432
|
+
return "PHPUnit configuration";
|
|
1433
|
+
}
|
|
1434
|
+
if (hasTestScript) {
|
|
1435
|
+
return '`"test"` script in package.json';
|
|
1436
|
+
}
|
|
1437
|
+
const testFile = await findTestFile(rootDir);
|
|
1438
|
+
if (testFile !== null) {
|
|
1439
|
+
return `\`${testFile}\``;
|
|
1440
|
+
}
|
|
1441
|
+
return null;
|
|
1442
|
+
}
|
|
1443
|
+
var TEST_FILE_PATTERNS = [
|
|
1444
|
+
/_test\.go$/u,
|
|
1445
|
+
/\.(test|spec)\.[cm]?[jt]sx?$/u,
|
|
1446
|
+
/^test_.+\.py$/u,
|
|
1447
|
+
/_test\.py$/u,
|
|
1448
|
+
/.+Tests?\.(java|kt)$/u,
|
|
1449
|
+
/.+Test\.php$/u,
|
|
1450
|
+
/_spec\.rb$/u,
|
|
1451
|
+
/_test\.rb$/u
|
|
1452
|
+
];
|
|
1453
|
+
var TEST_WALK_SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
1454
|
+
"node_modules",
|
|
1455
|
+
"vendor",
|
|
1456
|
+
"dist",
|
|
1457
|
+
"build",
|
|
1458
|
+
"target",
|
|
1459
|
+
"coverage",
|
|
1460
|
+
"Pods",
|
|
1461
|
+
"__pycache__"
|
|
1462
|
+
]);
|
|
1463
|
+
async function findTestFile(rootDir) {
|
|
1464
|
+
let budget = 4e3;
|
|
1465
|
+
const stack = [rootDir];
|
|
1466
|
+
while (stack.length > 0 && budget > 0) {
|
|
1467
|
+
const dir = stack.pop();
|
|
1468
|
+
if (dir === void 0) {
|
|
1469
|
+
break;
|
|
1470
|
+
}
|
|
1471
|
+
let entries;
|
|
1472
|
+
try {
|
|
1473
|
+
entries = await readdir4(dir, { withFileTypes: true });
|
|
1474
|
+
} catch {
|
|
1475
|
+
continue;
|
|
1476
|
+
}
|
|
1477
|
+
for (const entry of entries) {
|
|
1478
|
+
budget -= 1;
|
|
1479
|
+
if (budget <= 0) {
|
|
1480
|
+
break;
|
|
1481
|
+
}
|
|
1482
|
+
if (entry.isDirectory()) {
|
|
1483
|
+
if (!TEST_WALK_SKIP_DIRS.has(entry.name) && !entry.name.startsWith(".")) {
|
|
1484
|
+
stack.push(path6.join(dir, entry.name));
|
|
1485
|
+
}
|
|
1486
|
+
} else if (TEST_FILE_PATTERNS.some((pattern) => pattern.test(entry.name))) {
|
|
1487
|
+
return path6.relative(rootDir, path6.join(dir, entry.name));
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
return null;
|
|
1492
|
+
}
|
|
1404
1493
|
function collectDependencies(pkg) {
|
|
1405
1494
|
if (pkg === null) {
|
|
1406
1495
|
return {};
|
|
@@ -1428,6 +1517,100 @@ function isRecord(value) {
|
|
|
1428
1517
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1429
1518
|
}
|
|
1430
1519
|
|
|
1520
|
+
// src/core/adopt/generate-adoption.ts
|
|
1521
|
+
var ADOPTION_REPORT_PATH = "docs/adopt/ADOPTION_REPORT.md";
|
|
1522
|
+
function generateAdoptionFiles(options) {
|
|
1523
|
+
const files = [
|
|
1524
|
+
{
|
|
1525
|
+
path: ADOPTION_REPORT_PATH,
|
|
1526
|
+
content: renderReport(options.adrDir, options.signals)
|
|
1527
|
+
}
|
|
1528
|
+
];
|
|
1529
|
+
for (const framework of options.signals.frameworks) {
|
|
1530
|
+
files.push({
|
|
1531
|
+
path: `${options.adrDir}/proposed/ADR-PROPOSED-adopt-${frameworkSlug(framework)}.md`,
|
|
1532
|
+
content: renderProposedAdr(framework)
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
return files;
|
|
1536
|
+
}
|
|
1537
|
+
function renderReport(adrDir, signals) {
|
|
1538
|
+
return `# Adoption Report
|
|
1539
|
+
|
|
1540
|
+
## Status
|
|
1541
|
+
|
|
1542
|
+
Proposed. Everything below is inferred from this repository and requires human review. Nothing here
|
|
1543
|
+
is accepted repository memory until you accept it.
|
|
1544
|
+
|
|
1545
|
+
## Detected Signals
|
|
1546
|
+
|
|
1547
|
+
Each signal notes the file it was inferred from. If one is wrong, correct the source or edit this
|
|
1548
|
+
report \u2014 nothing here is accepted.
|
|
1549
|
+
|
|
1550
|
+
${summarizeSignals(signals).join("\n")}
|
|
1551
|
+
|
|
1552
|
+
## Proposed Decisions
|
|
1553
|
+
|
|
1554
|
+
${renderProposedDecisions(adrDir, signals)}
|
|
1555
|
+
|
|
1556
|
+
## Review Checklist
|
|
1557
|
+
|
|
1558
|
+
- [ ] Confirm the detected languages and package manager (and the source each was read from).
|
|
1559
|
+
- [ ] Confirm where tests were detected, or point Recall at the right location if it is wrong.
|
|
1560
|
+
- [ ] Accept or reject each proposed framework ADR under \`${adrDir}/proposed/\`.
|
|
1561
|
+
- [ ] Run \`recall init\` to establish neutral repository memory if it does not exist yet.
|
|
1562
|
+
- [ ] Record any decision you accept with \`recall adr create\` or by accepting the proposed ADR.
|
|
1563
|
+
|
|
1564
|
+
## Notes
|
|
1565
|
+
|
|
1566
|
+
This report was produced by \`recall adopt\` through read-only inspection of manifest and marker
|
|
1567
|
+
files. No repository code was executed and no decision was accepted automatically.
|
|
1568
|
+
`;
|
|
1569
|
+
}
|
|
1570
|
+
function renderProposedDecisions(adrDir, signals) {
|
|
1571
|
+
if (signals.frameworks.length === 0) {
|
|
1572
|
+
return "- No framework decisions were inferred. Add decisions with `recall adr create` as needed.";
|
|
1573
|
+
}
|
|
1574
|
+
return signals.frameworks.map(
|
|
1575
|
+
(framework) => `- Proposed: record **${framework}** as an architecture decision (see \`${adrDir}/proposed/ADR-PROPOSED-adopt-${frameworkSlug(framework)}.md\`). Requires review.`
|
|
1576
|
+
).join("\n");
|
|
1577
|
+
}
|
|
1578
|
+
function renderProposedAdr(framework) {
|
|
1579
|
+
return `# Proposed ADR: Use ${framework}
|
|
1580
|
+
|
|
1581
|
+
## Status
|
|
1582
|
+
|
|
1583
|
+
Proposed
|
|
1584
|
+
|
|
1585
|
+
## Context
|
|
1586
|
+
|
|
1587
|
+
\`recall adopt\` detected ${framework} in this repository through read-only inspection.
|
|
1588
|
+
|
|
1589
|
+
## Decision
|
|
1590
|
+
|
|
1591
|
+
Consider recording ${framework} as an accepted architecture decision. This is proposed by adoption
|
|
1592
|
+
and is not accepted until a human reviews and accepts it.
|
|
1593
|
+
|
|
1594
|
+
## Alternatives Considered
|
|
1595
|
+
|
|
1596
|
+
- Record a different framework.
|
|
1597
|
+
- Leave the decision unrecorded for now.
|
|
1598
|
+
|
|
1599
|
+
## Consequences
|
|
1600
|
+
|
|
1601
|
+
- Captures a framework already in use as reviewable repository memory.
|
|
1602
|
+
- Requires explicit human acceptance before it becomes repository truth.
|
|
1603
|
+
|
|
1604
|
+
## Related Documents
|
|
1605
|
+
|
|
1606
|
+
- \`docs/10-architecture/ARCHITECTURE.md\` \u2014 record the accepted architecture here once promoted.
|
|
1607
|
+
- The adoption report generated alongside this proposal.
|
|
1608
|
+
`;
|
|
1609
|
+
}
|
|
1610
|
+
function frameworkSlug(framework) {
|
|
1611
|
+
return framework.toLowerCase().replace(/\./gu, "").replace(/[^a-z0-9]+/gu, "-").replace(/^-+|-+$/gu, "");
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1431
1614
|
// src/commands/adopt.ts
|
|
1432
1615
|
var AdoptError = class extends Error {
|
|
1433
1616
|
code;
|
|
@@ -1499,19 +1682,102 @@ function formatList2(values) {
|
|
|
1499
1682
|
return values.length > 0 ? values.join(", ") : "none detected";
|
|
1500
1683
|
}
|
|
1501
1684
|
|
|
1502
|
-
// src/core/doctor/checks/
|
|
1503
|
-
import {
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1685
|
+
// src/core/doctor/checks/code-reference-check.ts
|
|
1686
|
+
import { existsSync as existsSync4 } from "fs";
|
|
1687
|
+
import { readFile as readFile4, readdir as readdir5 } from "fs/promises";
|
|
1688
|
+
import path7 from "path";
|
|
1689
|
+
var featureFolderPattern = /^F-\d{3,}-[a-z0-9]+(?:-[a-z0-9]+)*$/u;
|
|
1690
|
+
var FEATURE_DOCS = ["PRD.md", "ARCHITECTURE_IMPACT.md"];
|
|
1691
|
+
var MODULE_DOCS = ["MODULE.md", "DECISIONS.md"];
|
|
1692
|
+
var codePathPattern = /`((?:src|tests)\/[A-Za-z0-9._/-]+\.[A-Za-z0-9]+)`/gu;
|
|
1693
|
+
var placeholderMarkers = /[<>*]|\.\.\./u;
|
|
1694
|
+
async function checkCodeReferences(context) {
|
|
1695
|
+
if (context.config === void 0) {
|
|
1696
|
+
return [];
|
|
1697
|
+
}
|
|
1698
|
+
const findings = [];
|
|
1699
|
+
const featureEntries = await readDirIfExists(context.rootDir, context.config.featuresDir);
|
|
1700
|
+
for (const folder of featureEntries) {
|
|
1701
|
+
if (!folder.isDirectory() || !featureFolderPattern.test(folder.name)) {
|
|
1702
|
+
continue;
|
|
1703
|
+
}
|
|
1704
|
+
for (const doc of FEATURE_DOCS) {
|
|
1705
|
+
const relativePath = path7.posix.join(context.config.featuresDir, folder.name, doc);
|
|
1706
|
+
findings.push(...await checkDoc(context.rootDir, relativePath));
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
const moduleEntries = await readDirIfExists(context.rootDir, context.config.modulesDir);
|
|
1710
|
+
for (const folder of moduleEntries) {
|
|
1711
|
+
if (!folder.isDirectory()) {
|
|
1712
|
+
continue;
|
|
1713
|
+
}
|
|
1714
|
+
for (const doc of MODULE_DOCS) {
|
|
1715
|
+
const relativePath = path7.posix.join(context.config.modulesDir, folder.name, doc);
|
|
1716
|
+
findings.push(...await checkDoc(context.rootDir, relativePath));
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
return findings;
|
|
1720
|
+
}
|
|
1721
|
+
async function checkDoc(rootDir, relativePath) {
|
|
1722
|
+
const content = await readFileIfExists(rootDir, relativePath);
|
|
1723
|
+
if (content === void 0) {
|
|
1724
|
+
return [];
|
|
1725
|
+
}
|
|
1726
|
+
const findings = [];
|
|
1727
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1728
|
+
for (const match of content.matchAll(codePathPattern)) {
|
|
1729
|
+
const reference = match[1];
|
|
1730
|
+
if (placeholderMarkers.test(reference) || seen.has(reference)) {
|
|
1731
|
+
continue;
|
|
1732
|
+
}
|
|
1733
|
+
seen.add(reference);
|
|
1734
|
+
if (!existsSync4(path7.join(rootDir, reference))) {
|
|
1735
|
+
findings.push({
|
|
1736
|
+
severity: "warning",
|
|
1737
|
+
check: "drift-code-reference",
|
|
1738
|
+
message: `Repository memory references ${reference}, which does not exist.`,
|
|
1739
|
+
path: relativePath
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
return findings;
|
|
1744
|
+
}
|
|
1745
|
+
async function readDirIfExists(rootDir, relativePath) {
|
|
1507
1746
|
try {
|
|
1508
|
-
|
|
1747
|
+
return await readdir5(path7.join(rootDir, relativePath), { withFileTypes: true });
|
|
1509
1748
|
} catch (error) {
|
|
1510
1749
|
const nodeError = error;
|
|
1511
1750
|
if (nodeError.code === "ENOENT") {
|
|
1512
|
-
return
|
|
1513
|
-
|
|
1514
|
-
|
|
1751
|
+
return [];
|
|
1752
|
+
}
|
|
1753
|
+
throw error;
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
async function readFileIfExists(rootDir, relativePath) {
|
|
1757
|
+
try {
|
|
1758
|
+
return await readFile4(path7.join(rootDir, relativePath), "utf8");
|
|
1759
|
+
} catch (error) {
|
|
1760
|
+
const nodeError = error;
|
|
1761
|
+
if (nodeError.code === "ENOENT") {
|
|
1762
|
+
return void 0;
|
|
1763
|
+
}
|
|
1764
|
+
throw error;
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
// src/core/doctor/checks/config-check.ts
|
|
1769
|
+
import { readFile as readFile5 } from "fs/promises";
|
|
1770
|
+
async function checkConfig(rootDir) {
|
|
1771
|
+
const configPath = resolveSafePath(rootDir, CONFIG_PATH);
|
|
1772
|
+
let rawConfig;
|
|
1773
|
+
try {
|
|
1774
|
+
rawConfig = await readFile5(configPath.absolutePath, "utf8");
|
|
1775
|
+
} catch (error) {
|
|
1776
|
+
const nodeError = error;
|
|
1777
|
+
if (nodeError.code === "ENOENT") {
|
|
1778
|
+
return {
|
|
1779
|
+
findings: [
|
|
1780
|
+
{
|
|
1515
1781
|
severity: "error",
|
|
1516
1782
|
check: "config",
|
|
1517
1783
|
message: "Missing .recall/config.json.",
|
|
@@ -1568,21 +1834,24 @@ async function checkConfig(rootDir) {
|
|
|
1568
1834
|
}
|
|
1569
1835
|
|
|
1570
1836
|
// src/core/doctor/checks/content-check.ts
|
|
1571
|
-
import { readFile as
|
|
1572
|
-
import
|
|
1573
|
-
var
|
|
1837
|
+
import { readFile as readFile6, readdir as readdir6 } from "fs/promises";
|
|
1838
|
+
import path8 from "path";
|
|
1839
|
+
var featureFolderPattern2 = /^F-\d{3,}-[a-z0-9]+(?:-[a-z0-9]+)*$/u;
|
|
1840
|
+
var acceptedAdrPattern = /^ADR-\d{4,}-[a-z0-9]+(?:-[a-z0-9]+)*\.md$/u;
|
|
1841
|
+
var SECURITY_MODEL_PATH = "docs/20-security/SECURITY_MODEL.md";
|
|
1842
|
+
var THREAT_MODEL_PATH = "docs/20-security/THREAT_MODEL.md";
|
|
1574
1843
|
async function checkContent(context) {
|
|
1575
1844
|
if (context.config === void 0) {
|
|
1576
1845
|
return [];
|
|
1577
1846
|
}
|
|
1578
1847
|
const findings = [];
|
|
1579
|
-
const entries = await
|
|
1848
|
+
const entries = await readDirIfExists2(context.rootDir, context.config.featuresDir);
|
|
1580
1849
|
const featureFolders = entries.filter(
|
|
1581
|
-
(entry) => entry.isDirectory() &&
|
|
1850
|
+
(entry) => entry.isDirectory() && featureFolderPattern2.test(entry.name)
|
|
1582
1851
|
);
|
|
1583
1852
|
for (const folder of featureFolders) {
|
|
1584
|
-
const prdPath =
|
|
1585
|
-
const prd = await
|
|
1853
|
+
const prdPath = path8.posix.join(context.config.featuresDir, folder.name, "PRD.md");
|
|
1854
|
+
const prd = await readFileIfExists2(context.rootDir, prdPath);
|
|
1586
1855
|
if (prd === void 0) {
|
|
1587
1856
|
continue;
|
|
1588
1857
|
}
|
|
@@ -1603,6 +1872,61 @@ async function checkContent(context) {
|
|
|
1603
1872
|
});
|
|
1604
1873
|
}
|
|
1605
1874
|
}
|
|
1875
|
+
const moduleEntries = await readDirIfExists2(context.rootDir, context.config.modulesDir);
|
|
1876
|
+
const moduleFolders = moduleEntries.filter((entry) => entry.isDirectory());
|
|
1877
|
+
const adrEntries = await readDirIfExists2(context.rootDir, context.config.adrDir);
|
|
1878
|
+
const acceptedAdrs = adrEntries.filter(
|
|
1879
|
+
(entry) => entry.isFile() && acceptedAdrPattern.test(entry.name)
|
|
1880
|
+
);
|
|
1881
|
+
const hasWork = featureFolders.length > 0 || moduleFolders.length > 0 || acceptedAdrs.length > 0;
|
|
1882
|
+
if (hasWork) {
|
|
1883
|
+
findings.push(...await checkSecurityDoc(context.rootDir));
|
|
1884
|
+
}
|
|
1885
|
+
for (const folder of moduleFolders) {
|
|
1886
|
+
const modulePath = path8.posix.join(context.config.modulesDir, folder.name, "MODULE.md");
|
|
1887
|
+
const moduleDoc = await readFileIfExists2(context.rootDir, modulePath);
|
|
1888
|
+
if (moduleDoc === void 0) {
|
|
1889
|
+
continue;
|
|
1890
|
+
}
|
|
1891
|
+
if (sectionIsUnfilled(moduleDoc, "Purpose")) {
|
|
1892
|
+
findings.push({
|
|
1893
|
+
severity: "warning",
|
|
1894
|
+
check: "content-module",
|
|
1895
|
+
message: "Module memory purpose is still an unfilled template.",
|
|
1896
|
+
path: modulePath
|
|
1897
|
+
});
|
|
1898
|
+
}
|
|
1899
|
+
if (sectionIsUnfilled(moduleDoc, "Owns")) {
|
|
1900
|
+
findings.push({
|
|
1901
|
+
severity: "warning",
|
|
1902
|
+
check: "content-module",
|
|
1903
|
+
message: "Module memory owns section is still an unfilled template.",
|
|
1904
|
+
path: modulePath
|
|
1905
|
+
});
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
return findings;
|
|
1909
|
+
}
|
|
1910
|
+
async function checkSecurityDoc(rootDir) {
|
|
1911
|
+
const findings = [];
|
|
1912
|
+
const security = await readFileIfExists2(rootDir, SECURITY_MODEL_PATH);
|
|
1913
|
+
if (security !== void 0 && sectionIsUnfilled(security, "Authentication And Authorization")) {
|
|
1914
|
+
findings.push({
|
|
1915
|
+
severity: "warning",
|
|
1916
|
+
check: "content-security",
|
|
1917
|
+
message: "Security model authentication and authorization section is still an unfilled template.",
|
|
1918
|
+
path: SECURITY_MODEL_PATH
|
|
1919
|
+
});
|
|
1920
|
+
}
|
|
1921
|
+
const threat = await readFileIfExists2(rootDir, THREAT_MODEL_PATH);
|
|
1922
|
+
if (threat !== void 0 && sectionIsUnfilled(threat, "Assets")) {
|
|
1923
|
+
findings.push({
|
|
1924
|
+
severity: "warning",
|
|
1925
|
+
check: "content-threat-model",
|
|
1926
|
+
message: "Threat model assets section is still an unfilled template.",
|
|
1927
|
+
path: THREAT_MODEL_PATH
|
|
1928
|
+
});
|
|
1929
|
+
}
|
|
1606
1930
|
return findings;
|
|
1607
1931
|
}
|
|
1608
1932
|
function sectionIsUnfilled(content, heading) {
|
|
@@ -1617,7 +1941,7 @@ function isUnfilled(value) {
|
|
|
1617
1941
|
if (normalized === "tbd" || normalized === "todo" || normalized === "pending" || normalized === "none" || normalized === "n/a") {
|
|
1618
1942
|
return true;
|
|
1619
1943
|
}
|
|
1620
|
-
return normalized.includes("describe why this feature exists");
|
|
1944
|
+
return normalized.includes("describe why this feature exists") || normalized.includes("describe what this module owns") || normalized.includes("describe how this repository authenticates") || normalized.includes("describe what this repository must protect");
|
|
1621
1945
|
}
|
|
1622
1946
|
function getSection(content, heading) {
|
|
1623
1947
|
const lines = content.split(/\r?\n/u);
|
|
@@ -1635,9 +1959,9 @@ function getSection(content, heading) {
|
|
|
1635
1959
|
}
|
|
1636
1960
|
return body.join("\n").trim();
|
|
1637
1961
|
}
|
|
1638
|
-
async function
|
|
1962
|
+
async function readDirIfExists2(rootDir, relativePath) {
|
|
1639
1963
|
try {
|
|
1640
|
-
return await
|
|
1964
|
+
return await readdir6(path8.join(rootDir, relativePath), { withFileTypes: true });
|
|
1641
1965
|
} catch (error) {
|
|
1642
1966
|
const nodeError = error;
|
|
1643
1967
|
if (nodeError.code === "ENOENT") {
|
|
@@ -1646,9 +1970,9 @@ async function readDirIfExists(rootDir, relativePath) {
|
|
|
1646
1970
|
throw error;
|
|
1647
1971
|
}
|
|
1648
1972
|
}
|
|
1649
|
-
async function
|
|
1973
|
+
async function readFileIfExists2(rootDir, relativePath) {
|
|
1650
1974
|
try {
|
|
1651
|
-
return await
|
|
1975
|
+
return await readFile6(path8.join(rootDir, relativePath), "utf8");
|
|
1652
1976
|
} catch (error) {
|
|
1653
1977
|
const nodeError = error;
|
|
1654
1978
|
if (nodeError.code === "ENOENT") {
|
|
@@ -1659,8 +1983,8 @@ async function readFileIfExists(rootDir, relativePath) {
|
|
|
1659
1983
|
}
|
|
1660
1984
|
|
|
1661
1985
|
// src/core/doctor/checks/drift-check.ts
|
|
1662
|
-
import { readFile as
|
|
1663
|
-
import
|
|
1986
|
+
import { readFile as readFile7, readdir as readdir7 } from "fs/promises";
|
|
1987
|
+
import path9 from "path";
|
|
1664
1988
|
var adrFilePattern = /^ADR-(\d{4,})-[a-z0-9]+(?:-[a-z0-9]+)*\.md$/iu;
|
|
1665
1989
|
var adrReferencePattern = /ADR-\d{4,}/giu;
|
|
1666
1990
|
async function checkDrift(context) {
|
|
@@ -1677,12 +2001,12 @@ async function loadKnownAdrs(rootDir, adrDir) {
|
|
|
1677
2001
|
const known = /* @__PURE__ */ new Map();
|
|
1678
2002
|
const files = await readMarkdownFiles(rootDir, adrDir);
|
|
1679
2003
|
for (const file of files) {
|
|
1680
|
-
const match = adrFilePattern.exec(
|
|
2004
|
+
const match = adrFilePattern.exec(path9.basename(file));
|
|
1681
2005
|
if (match === null) {
|
|
1682
2006
|
continue;
|
|
1683
2007
|
}
|
|
1684
2008
|
const id = `ADR-${match[1]}`;
|
|
1685
|
-
const content = await
|
|
2009
|
+
const content = await readFile7(path9.join(rootDir, file), "utf8");
|
|
1686
2010
|
const accepted = sectionContains(content, "Status", /\baccepted\b/iu);
|
|
1687
2011
|
const existing = known.get(id);
|
|
1688
2012
|
if (existing === void 0 || !existing.accepted && accepted) {
|
|
@@ -1695,7 +2019,7 @@ async function checkReferences(rootDir, referenceDir, knownAdrs) {
|
|
|
1695
2019
|
const findings = [];
|
|
1696
2020
|
const files = await readMarkdownFiles(rootDir, referenceDir);
|
|
1697
2021
|
for (const file of files) {
|
|
1698
|
-
const content = await
|
|
2022
|
+
const content = await readFile7(path9.join(rootDir, file), "utf8");
|
|
1699
2023
|
const referenced = /* @__PURE__ */ new Set();
|
|
1700
2024
|
for (const match of stripCode(content).matchAll(adrReferencePattern)) {
|
|
1701
2025
|
referenced.add(match[0].toUpperCase());
|
|
@@ -1727,10 +2051,10 @@ function stripCode(content) {
|
|
|
1727
2051
|
return content.replace(/```[\s\S]*?```/gu, " ").replace(/~~~[\s\S]*?~~~/gu, " ").replace(/`[^`]*`/gu, " ");
|
|
1728
2052
|
}
|
|
1729
2053
|
async function readMarkdownFiles(rootDir, relativeDir) {
|
|
1730
|
-
const entries = await
|
|
2054
|
+
const entries = await readDirIfExists3(rootDir, relativeDir);
|
|
1731
2055
|
const files = [];
|
|
1732
2056
|
for (const entry of entries) {
|
|
1733
|
-
const childRelative =
|
|
2057
|
+
const childRelative = path9.posix.join(relativeDir, entry.name);
|
|
1734
2058
|
if (entry.isDirectory()) {
|
|
1735
2059
|
files.push(...await readMarkdownFiles(rootDir, childRelative));
|
|
1736
2060
|
continue;
|
|
@@ -1761,9 +2085,9 @@ function getSection2(content, heading) {
|
|
|
1761
2085
|
}
|
|
1762
2086
|
return body.join("\n").trim();
|
|
1763
2087
|
}
|
|
1764
|
-
async function
|
|
2088
|
+
async function readDirIfExists3(rootDir, relativePath) {
|
|
1765
2089
|
try {
|
|
1766
|
-
return await
|
|
2090
|
+
return await readdir7(path9.join(rootDir, relativePath), { withFileTypes: true });
|
|
1767
2091
|
} catch (error) {
|
|
1768
2092
|
const nodeError = error;
|
|
1769
2093
|
if (nodeError.code === "ENOENT") {
|
|
@@ -1774,9 +2098,39 @@ async function readDirIfExists2(rootDir, relativePath) {
|
|
|
1774
2098
|
}
|
|
1775
2099
|
|
|
1776
2100
|
// src/core/doctor/checks/memory-integrity-check.ts
|
|
1777
|
-
import { lstat as lstat2, readFile as
|
|
1778
|
-
import
|
|
1779
|
-
|
|
2101
|
+
import { lstat as lstat2, readFile as readFile8, readdir as readdir8 } from "fs/promises";
|
|
2102
|
+
import path10 from "path";
|
|
2103
|
+
|
|
2104
|
+
// src/core/adr/adr-sections.ts
|
|
2105
|
+
var REQUIRED_ADR_SECTIONS = [
|
|
2106
|
+
"## Status",
|
|
2107
|
+
"## Context",
|
|
2108
|
+
"## Decision",
|
|
2109
|
+
"## Alternatives Considered",
|
|
2110
|
+
"## Consequences",
|
|
2111
|
+
"## Related Documents"
|
|
2112
|
+
];
|
|
2113
|
+
var SECTION_PLACEHOLDERS = {
|
|
2114
|
+
"## Related Documents": "- None yet. Link related ADRs, features, or modules as they are accepted."
|
|
2115
|
+
};
|
|
2116
|
+
function ensureRequiredAdrSections(body) {
|
|
2117
|
+
let result = body.replace(/\s+$/u, "");
|
|
2118
|
+
for (const section of REQUIRED_ADR_SECTIONS) {
|
|
2119
|
+
if (!result.includes(section)) {
|
|
2120
|
+
const placeholder = SECTION_PLACEHOLDERS[section] ?? "To be documented.";
|
|
2121
|
+
result += `
|
|
2122
|
+
|
|
2123
|
+
${section}
|
|
2124
|
+
|
|
2125
|
+
${placeholder}`;
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
return `${result}
|
|
2129
|
+
`;
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2132
|
+
// src/core/doctor/checks/memory-integrity-check.ts
|
|
2133
|
+
var featureFolderPattern3 = /^F-\d{3,}-[a-z0-9]+(?:-[a-z0-9]+)*$/u;
|
|
1780
2134
|
var adrFilePattern2 = /^ADR-\d{4,}-[a-z0-9]+(?:-[a-z0-9]+)*\.md$/u;
|
|
1781
2135
|
var requiredFeatureDocs = [
|
|
1782
2136
|
"PRD.md",
|
|
@@ -1790,14 +2144,7 @@ var requiredFeatureDocs = [
|
|
|
1790
2144
|
"COMPLETION_REPORT.md"
|
|
1791
2145
|
];
|
|
1792
2146
|
var requiredModuleDocs = ["MODULE.md", "TASKS.md", "TEST_PLAN.md", "DECISIONS.md"];
|
|
1793
|
-
var requiredAdrSections =
|
|
1794
|
-
"## Status",
|
|
1795
|
-
"## Context",
|
|
1796
|
-
"## Decision",
|
|
1797
|
-
"## Alternatives Considered",
|
|
1798
|
-
"## Consequences",
|
|
1799
|
-
"## Related Documents"
|
|
1800
|
-
];
|
|
2147
|
+
var requiredAdrSections = REQUIRED_ADR_SECTIONS;
|
|
1801
2148
|
async function checkMemoryIntegrity(context) {
|
|
1802
2149
|
if (context.config === void 0) {
|
|
1803
2150
|
return [];
|
|
@@ -1810,13 +2157,13 @@ async function checkMemoryIntegrity(context) {
|
|
|
1810
2157
|
}
|
|
1811
2158
|
async function checkFeatureFolders(rootDir, featuresDir) {
|
|
1812
2159
|
const findings = [];
|
|
1813
|
-
const entries = await
|
|
2160
|
+
const entries = await readDirIfExists4(rootDir, featuresDir);
|
|
1814
2161
|
const featureFolders = entries.filter(
|
|
1815
|
-
(entry) => entry.isDirectory() &&
|
|
2162
|
+
(entry) => entry.isDirectory() && featureFolderPattern3.test(entry.name)
|
|
1816
2163
|
);
|
|
1817
2164
|
for (const featureFolder of featureFolders) {
|
|
1818
2165
|
for (const requiredDoc of requiredFeatureDocs) {
|
|
1819
|
-
const filePath =
|
|
2166
|
+
const filePath = path10.posix.join(featuresDir, featureFolder.name, requiredDoc);
|
|
1820
2167
|
if (!await isFile(rootDir, filePath)) {
|
|
1821
2168
|
findings.push({
|
|
1822
2169
|
severity: "error",
|
|
@@ -1836,11 +2183,11 @@ async function checkFeatureFolders(rootDir, featuresDir) {
|
|
|
1836
2183
|
}
|
|
1837
2184
|
async function checkModuleFolders(rootDir, modulesDir) {
|
|
1838
2185
|
const findings = [];
|
|
1839
|
-
const entries = await
|
|
2186
|
+
const entries = await readDirIfExists4(rootDir, modulesDir);
|
|
1840
2187
|
const moduleFolders = entries.filter((entry) => entry.isDirectory());
|
|
1841
2188
|
for (const moduleFolder of moduleFolders) {
|
|
1842
2189
|
for (const requiredDoc of requiredModuleDocs) {
|
|
1843
|
-
const filePath =
|
|
2190
|
+
const filePath = path10.posix.join(modulesDir, moduleFolder.name, requiredDoc);
|
|
1844
2191
|
if (!await isFile(rootDir, filePath)) {
|
|
1845
2192
|
findings.push({
|
|
1846
2193
|
severity: "error",
|
|
@@ -1860,11 +2207,11 @@ async function checkModuleFolders(rootDir, modulesDir) {
|
|
|
1860
2207
|
}
|
|
1861
2208
|
async function checkAdrFiles(rootDir, adrDir) {
|
|
1862
2209
|
const findings = [];
|
|
1863
|
-
const entries = await
|
|
2210
|
+
const entries = await readDirIfExists4(rootDir, adrDir);
|
|
1864
2211
|
const adrFiles = entries.filter((entry) => entry.isFile() && adrFilePattern2.test(entry.name));
|
|
1865
2212
|
for (const adrFile of adrFiles) {
|
|
1866
|
-
const filePath =
|
|
1867
|
-
const content = await
|
|
2213
|
+
const filePath = path10.posix.join(adrDir, adrFile.name);
|
|
2214
|
+
const content = await readFile8(path10.join(rootDir, filePath), "utf8");
|
|
1868
2215
|
for (const requiredSection of requiredAdrSections) {
|
|
1869
2216
|
if (!content.includes(requiredSection)) {
|
|
1870
2217
|
findings.push({
|
|
@@ -1883,9 +2230,9 @@ async function checkAdrFiles(rootDir, adrDir) {
|
|
|
1883
2230
|
});
|
|
1884
2231
|
return findings;
|
|
1885
2232
|
}
|
|
1886
|
-
async function
|
|
2233
|
+
async function readDirIfExists4(rootDir, relativePath) {
|
|
1887
2234
|
try {
|
|
1888
|
-
return await
|
|
2235
|
+
return await readdir8(path10.join(rootDir, relativePath), { withFileTypes: true });
|
|
1889
2236
|
} catch (error) {
|
|
1890
2237
|
const nodeError = error;
|
|
1891
2238
|
if (nodeError.code === "ENOENT") {
|
|
@@ -1896,7 +2243,7 @@ async function readDirIfExists3(rootDir, relativePath) {
|
|
|
1896
2243
|
}
|
|
1897
2244
|
async function isFile(rootDir, relativePath) {
|
|
1898
2245
|
try {
|
|
1899
|
-
return (await lstat2(
|
|
2246
|
+
return (await lstat2(path10.join(rootDir, relativePath))).isFile();
|
|
1900
2247
|
} catch (error) {
|
|
1901
2248
|
const nodeError = error;
|
|
1902
2249
|
if (nodeError.code === "ENOENT") {
|
|
@@ -1908,7 +2255,7 @@ async function isFile(rootDir, relativePath) {
|
|
|
1908
2255
|
|
|
1909
2256
|
// src/core/doctor/checks/required-files-check.ts
|
|
1910
2257
|
import { lstat as lstat3 } from "fs/promises";
|
|
1911
|
-
import
|
|
2258
|
+
import path11 from "path";
|
|
1912
2259
|
var rootFiles = ["AGENTS.md", "CLAUDE.md"];
|
|
1913
2260
|
var requiredDocs = [
|
|
1914
2261
|
"00-product/PRD.md",
|
|
@@ -1935,12 +2282,12 @@ async function checkRequiredFiles(context) {
|
|
|
1935
2282
|
}
|
|
1936
2283
|
}
|
|
1937
2284
|
for (const relativeDocPath of requiredDocs) {
|
|
1938
|
-
const filePath =
|
|
2285
|
+
const filePath = path11.posix.join(docsDir, relativeDocPath);
|
|
1939
2286
|
if (!await isFile2(context.rootDir, filePath)) {
|
|
1940
2287
|
findings.push(missingFile(filePath, "required-docs"));
|
|
1941
2288
|
}
|
|
1942
2289
|
}
|
|
1943
|
-
const adrIndexPath =
|
|
2290
|
+
const adrIndexPath = path11.posix.join(context.config?.adrDir ?? "docs/adrs", "README.md");
|
|
1944
2291
|
if (!await isFile2(context.rootDir, adrIndexPath)) {
|
|
1945
2292
|
findings.push(missingFile(adrIndexPath, "required-docs"));
|
|
1946
2293
|
}
|
|
@@ -1966,7 +2313,7 @@ async function checkRequiredFiles(context) {
|
|
|
1966
2313
|
}
|
|
1967
2314
|
async function isFile2(rootDir, relativePath) {
|
|
1968
2315
|
try {
|
|
1969
|
-
return (await lstat3(
|
|
2316
|
+
return (await lstat3(path11.join(rootDir, relativePath))).isFile();
|
|
1970
2317
|
} catch (error) {
|
|
1971
2318
|
const nodeError = error;
|
|
1972
2319
|
if (nodeError.code === "ENOENT") {
|
|
@@ -1977,7 +2324,7 @@ async function isFile2(rootDir, relativePath) {
|
|
|
1977
2324
|
}
|
|
1978
2325
|
async function isDirectory(rootDir, relativePath) {
|
|
1979
2326
|
try {
|
|
1980
|
-
return (await lstat3(
|
|
2327
|
+
return (await lstat3(path11.join(rootDir, relativePath))).isDirectory();
|
|
1981
2328
|
} catch (error) {
|
|
1982
2329
|
const nodeError = error;
|
|
1983
2330
|
if (nodeError.code === "ENOENT") {
|
|
@@ -1996,9 +2343,9 @@ function missingFile(pathValue, check) {
|
|
|
1996
2343
|
}
|
|
1997
2344
|
|
|
1998
2345
|
// src/core/doctor/checks/standards-check.ts
|
|
1999
|
-
import { lstat as lstat4, readFile as
|
|
2000
|
-
import
|
|
2001
|
-
var
|
|
2346
|
+
import { lstat as lstat4, readFile as readFile9, readdir as readdir9 } from "fs/promises";
|
|
2347
|
+
import path12 from "path";
|
|
2348
|
+
var featureFolderPattern4 = /^F-\d{3,}-[a-z0-9]+(?:-[a-z0-9]+)*$/u;
|
|
2002
2349
|
var adrFilePattern3 = /^ADR-\d{4,}-[a-z0-9]+(?:-[a-z0-9]+)*\.md$/u;
|
|
2003
2350
|
var securitySensitivePattern = /\b(auth|authentication|authorization|secrets?|storage|networking?|telemetry|file writes?|write policy|dependencies?|mcp|ai api|cloud|runtime)\b/iu;
|
|
2004
2351
|
async function checkStandards(context) {
|
|
@@ -2012,18 +2359,18 @@ async function checkStandards(context) {
|
|
|
2012
2359
|
}
|
|
2013
2360
|
async function checkFeatureStandards(rootDir, featuresDir) {
|
|
2014
2361
|
const findings = [];
|
|
2015
|
-
const entries = await
|
|
2362
|
+
const entries = await readDirIfExists5(rootDir, featuresDir);
|
|
2016
2363
|
const featureFolders = entries.filter(
|
|
2017
|
-
(entry) => entry.isDirectory() &&
|
|
2364
|
+
(entry) => entry.isDirectory() && featureFolderPattern4.test(entry.name)
|
|
2018
2365
|
);
|
|
2019
2366
|
for (const featureFolder of featureFolders) {
|
|
2020
|
-
const featureDir =
|
|
2021
|
-
const completionReportPath =
|
|
2022
|
-
const reviewPath =
|
|
2023
|
-
const architectureImpactPath =
|
|
2024
|
-
const completionReport = await
|
|
2025
|
-
const review = await
|
|
2026
|
-
const architectureImpact = await
|
|
2367
|
+
const featureDir = path12.posix.join(featuresDir, featureFolder.name);
|
|
2368
|
+
const completionReportPath = path12.posix.join(featureDir, "COMPLETION_REPORT.md");
|
|
2369
|
+
const reviewPath = path12.posix.join(featureDir, "REVIEW.md");
|
|
2370
|
+
const architectureImpactPath = path12.posix.join(featureDir, "ARCHITECTURE_IMPACT.md");
|
|
2371
|
+
const completionReport = await readFileIfExists3(rootDir, completionReportPath);
|
|
2372
|
+
const review = await readFileIfExists3(rootDir, reviewPath);
|
|
2373
|
+
const architectureImpact = await readFileIfExists3(rootDir, architectureImpactPath);
|
|
2027
2374
|
if (completionReport !== void 0) {
|
|
2028
2375
|
const featureIsComplete = sectionContains2(completionReport, "Status", /\bcomplete\b/iu);
|
|
2029
2376
|
if (featureIsComplete) {
|
|
@@ -2067,11 +2414,11 @@ async function checkFeatureStandards(rootDir, featuresDir) {
|
|
|
2067
2414
|
}
|
|
2068
2415
|
async function checkAdrStandards(rootDir, adrDir) {
|
|
2069
2416
|
const findings = [];
|
|
2070
|
-
const entries = await
|
|
2417
|
+
const entries = await readDirIfExists5(rootDir, adrDir);
|
|
2071
2418
|
const adrFiles = entries.filter((entry) => entry.isFile() && adrFilePattern3.test(entry.name));
|
|
2072
2419
|
for (const adrFile of adrFiles) {
|
|
2073
|
-
const adrPath =
|
|
2074
|
-
const content = await
|
|
2420
|
+
const adrPath = path12.posix.join(adrDir, adrFile.name);
|
|
2421
|
+
const content = await readFile9(path12.join(rootDir, adrPath), "utf8");
|
|
2075
2422
|
const isAccepted = sectionContains2(content, "Status", /\baccepted\b/iu);
|
|
2076
2423
|
if (!hasMeaningfulSection(content, "Consequences")) {
|
|
2077
2424
|
findings.push({
|
|
@@ -2153,9 +2500,9 @@ function isPlaceholder(value) {
|
|
|
2153
2500
|
}
|
|
2154
2501
|
return normalized.includes("implementation is in progress") || normalized.includes("will be completed after implementation");
|
|
2155
2502
|
}
|
|
2156
|
-
async function
|
|
2503
|
+
async function readDirIfExists5(rootDir, relativePath) {
|
|
2157
2504
|
try {
|
|
2158
|
-
return await
|
|
2505
|
+
return await readdir9(path12.join(rootDir, relativePath), { withFileTypes: true });
|
|
2159
2506
|
} catch (error) {
|
|
2160
2507
|
const nodeError = error;
|
|
2161
2508
|
if (nodeError.code === "ENOENT") {
|
|
@@ -2164,12 +2511,12 @@ async function readDirIfExists4(rootDir, relativePath) {
|
|
|
2164
2511
|
throw error;
|
|
2165
2512
|
}
|
|
2166
2513
|
}
|
|
2167
|
-
async function
|
|
2514
|
+
async function readFileIfExists3(rootDir, relativePath) {
|
|
2168
2515
|
try {
|
|
2169
2516
|
if (!await isFile3(rootDir, relativePath)) {
|
|
2170
2517
|
return void 0;
|
|
2171
2518
|
}
|
|
2172
|
-
return await
|
|
2519
|
+
return await readFile9(path12.join(rootDir, relativePath), "utf8");
|
|
2173
2520
|
} catch (error) {
|
|
2174
2521
|
const nodeError = error;
|
|
2175
2522
|
if (nodeError.code === "ENOENT") {
|
|
@@ -2180,7 +2527,7 @@ async function readFileIfExists2(rootDir, relativePath) {
|
|
|
2180
2527
|
}
|
|
2181
2528
|
async function isFile3(rootDir, relativePath) {
|
|
2182
2529
|
try {
|
|
2183
|
-
return (await lstat4(
|
|
2530
|
+
return (await lstat4(path12.join(rootDir, relativePath))).isFile();
|
|
2184
2531
|
} catch (error) {
|
|
2185
2532
|
const nodeError = error;
|
|
2186
2533
|
if (nodeError.code === "ENOENT") {
|
|
@@ -2205,6 +2552,7 @@ async function runDoctor(rootDir) {
|
|
|
2205
2552
|
findings.push(...await checkStandards(context));
|
|
2206
2553
|
findings.push(...await checkDrift(context));
|
|
2207
2554
|
findings.push(...await checkContent(context));
|
|
2555
|
+
findings.push(...await checkCodeReferences(context));
|
|
2208
2556
|
}
|
|
2209
2557
|
return createDoctorReport(findings);
|
|
2210
2558
|
}
|
|
@@ -2281,11 +2629,11 @@ function formatDoctorResult(result) {
|
|
|
2281
2629
|
}
|
|
2282
2630
|
|
|
2283
2631
|
// src/commands/init.ts
|
|
2284
|
-
import { existsSync as
|
|
2285
|
-
import
|
|
2632
|
+
import { existsSync as existsSync6 } from "fs";
|
|
2633
|
+
import path15 from "path";
|
|
2286
2634
|
|
|
2287
2635
|
// src/core/generator/generate-init.ts
|
|
2288
|
-
import
|
|
2636
|
+
import path13 from "path";
|
|
2289
2637
|
var neutralTemplates = [
|
|
2290
2638
|
{
|
|
2291
2639
|
path: "AGENTS.md",
|
|
@@ -2310,11 +2658,41 @@ Repository rules override model preferences. If instructions conflict, stop and
|
|
|
2310
2658
|
path: "CLAUDE.md",
|
|
2311
2659
|
content: `# {{repositoryName}} Claude Instructions
|
|
2312
2660
|
|
|
2313
|
-
|
|
2661
|
+
This file is loaded automatically every Claude session. The durable project memory lives in \`docs/\`;
|
|
2662
|
+
do not rely on chat history as source of truth, and repository rules override model preference.
|
|
2663
|
+
|
|
2664
|
+
@AGENTS.md
|
|
2665
|
+
|
|
2666
|
+
Read the docs that \`AGENTS.md\` routes to before changing code or repository memory. A SessionStart
|
|
2667
|
+
hook (\`.claude/hooks/session-start.sh\`) also injects a memory map at the start of each session.
|
|
2668
|
+
`
|
|
2669
|
+
},
|
|
2670
|
+
{
|
|
2671
|
+
// Cursor auto-applies rules under .cursor/rules. alwaysApply makes this the portable equivalent
|
|
2672
|
+
// of the Claude Code SessionStart hook: Cursor injects it into every request so the agent loads
|
|
2673
|
+
// repository memory even though it cannot run the Claude-specific hook.
|
|
2674
|
+
path: ".cursor/rules/recall-memory.mdc",
|
|
2675
|
+
content: `---
|
|
2676
|
+
description: {{repositoryName}} repository memory and rules (Recall OS). Read before non-trivial work.
|
|
2677
|
+
globs:
|
|
2678
|
+
alwaysApply: true
|
|
2679
|
+
---
|
|
2680
|
+
|
|
2681
|
+
# {{repositoryName}} repository memory
|
|
2682
|
+
|
|
2683
|
+
This repository uses Recall OS. Durable memory lives in \`docs/\` and is the source of truth over chat
|
|
2684
|
+
history. Do not treat chat history as truth, and repository rules override model preference.
|
|
2685
|
+
|
|
2686
|
+
Before non-trivial work:
|
|
2314
2687
|
|
|
2315
|
-
|
|
2688
|
+
- Read \`AGENTS.md\` and the docs it routes to.
|
|
2689
|
+
- Accepted decisions live in \`docs/adrs/\`; module memory lives in \`docs/30-modules/\`.
|
|
2690
|
+
- If an instruction conflicts with accepted repository memory, stop and report the conflict.
|
|
2316
2691
|
|
|
2317
|
-
|
|
2692
|
+
Source-of-truth order: accepted ADRs and repository decisions, then architecture docs, engineering
|
|
2693
|
+
standards, the current PRD, security and testing docs, module docs, feature plans, then chat history.
|
|
2694
|
+
|
|
2695
|
+
Before claiming work is complete, run \`recall doctor\` and fix reported errors.
|
|
2318
2696
|
`
|
|
2319
2697
|
},
|
|
2320
2698
|
{
|
|
@@ -2398,26 +2776,78 @@ Default behavior:
|
|
|
2398
2776
|
path: "docs/20-security/SECURITY_MODEL.md",
|
|
2399
2777
|
content: `# Security Model
|
|
2400
2778
|
|
|
2401
|
-
##
|
|
2779
|
+
## Status
|
|
2402
2780
|
|
|
2403
|
-
Draft.
|
|
2781
|
+
Draft \u2014 fill the prompted sections below with this repository's real model as it grows. \`recall doctor\`
|
|
2782
|
+
flags these as warnings once the repository has real work (a feature, module, or accepted decision).
|
|
2404
2783
|
|
|
2405
2784
|
## Baseline Rules
|
|
2406
2785
|
|
|
2407
|
-
-
|
|
2408
|
-
-
|
|
2786
|
+
- Never commit secrets or credentials, and never read or copy \`.env\` files into docs.
|
|
2787
|
+
- Validate and authorize untrusted input at every trust boundary.
|
|
2409
2788
|
- Do not add network, telemetry, cloud, MCP runtime, or AI API behavior without explicit review.
|
|
2789
|
+
|
|
2790
|
+
## Authentication And Authorization
|
|
2791
|
+
|
|
2792
|
+
Describe how this repository authenticates users or clients and how it authorizes actions, including
|
|
2793
|
+
where those checks live.
|
|
2794
|
+
|
|
2795
|
+
## Secrets And Configuration
|
|
2796
|
+
|
|
2797
|
+
Describe where secrets live, how they are injected, and how configuration is kept out of version
|
|
2798
|
+
control.
|
|
2799
|
+
|
|
2800
|
+
## Sensitive Data
|
|
2801
|
+
|
|
2802
|
+
Describe the sensitive or personal data this repository handles, and how it is protected at rest and
|
|
2803
|
+
in transit.
|
|
2804
|
+
|
|
2805
|
+
## Dependencies And Supply Chain
|
|
2806
|
+
|
|
2807
|
+
Describe how third-party dependencies are vetted, pinned, and updated.
|
|
2410
2808
|
`
|
|
2411
2809
|
},
|
|
2412
2810
|
{
|
|
2413
2811
|
path: "docs/20-security/THREAT_MODEL.md",
|
|
2414
2812
|
content: `# Threat Model
|
|
2415
2813
|
|
|
2416
|
-
##
|
|
2814
|
+
## Status
|
|
2417
2815
|
|
|
2418
|
-
Draft.
|
|
2816
|
+
Draft \u2014 replace the prompts below with this repository's real analysis as it grows. \`recall doctor\`
|
|
2817
|
+
flags these as warnings once the repository has real work (a feature, module, or accepted decision).
|
|
2818
|
+
|
|
2819
|
+
## Assets
|
|
2820
|
+
|
|
2821
|
+
Describe what this repository must protect: user data, credentials, money, availability, or
|
|
2822
|
+
reputation.
|
|
2823
|
+
|
|
2824
|
+
## Entry Points
|
|
2825
|
+
|
|
2826
|
+
Describe where untrusted input enters: HTTP endpoints, webhooks, file uploads, queues, CLI input, or
|
|
2827
|
+
third-party callbacks.
|
|
2828
|
+
|
|
2829
|
+
## Trust Boundaries
|
|
2419
2830
|
|
|
2420
|
-
|
|
2831
|
+
Describe where trust changes: client to server, service to database, your code to third-party APIs.
|
|
2832
|
+
|
|
2833
|
+
## Threats
|
|
2834
|
+
|
|
2835
|
+
Describe the concrete threats that apply to this repository, by category:
|
|
2836
|
+
|
|
2837
|
+
- Spoofing \u2014 how identities are faked or sessions stolen.
|
|
2838
|
+
- Tampering \u2014 how requests, data, or builds are altered (injection, mass assignment).
|
|
2839
|
+
- Repudiation \u2014 actions that must remain auditable.
|
|
2840
|
+
- Information disclosure \u2014 how sensitive data or secrets could leak.
|
|
2841
|
+
- Denial of service \u2014 how the system can be overwhelmed or abused.
|
|
2842
|
+
- Elevation of privilege \u2014 how a user could gain access they should not have.
|
|
2843
|
+
|
|
2844
|
+
## Mitigations
|
|
2845
|
+
|
|
2846
|
+
Describe the control in place or planned for each threat above.
|
|
2847
|
+
|
|
2848
|
+
## Open Risks
|
|
2849
|
+
|
|
2850
|
+
Describe accepted or unresolved risks and who owns them.
|
|
2421
2851
|
`
|
|
2422
2852
|
},
|
|
2423
2853
|
{
|
|
@@ -2670,14 +3100,38 @@ Agents should not implement meaningful feature work without a feature plan or cl
|
|
|
2670
3100
|
path: "docs/adrs/README.md",
|
|
2671
3101
|
content: `# Architecture Decision Records
|
|
2672
3102
|
|
|
2673
|
-
Accepted
|
|
3103
|
+
Accepted ADRs live in this directory as \`ADR-####-<slug>.md\` with \`## Status\` set to \`Accepted\`.
|
|
3104
|
+
Proposed ADRs live under \`docs/adrs/proposed/\`.
|
|
3105
|
+
|
|
3106
|
+
There is no \`accepted/\` subdirectory: accepted ADRs sit at the top level of \`docs/adrs/\`.
|
|
2674
3107
|
|
|
2675
|
-
Presets and AI agents may propose decisions
|
|
3108
|
+
Presets and AI agents may propose decisions; humans accept them with \`recall adr accept <name>\`,
|
|
3109
|
+
which promotes a proposal into an accepted ADR here.
|
|
3110
|
+
`
|
|
3111
|
+
},
|
|
3112
|
+
{
|
|
3113
|
+
path: ".github/workflows/recall.yml",
|
|
3114
|
+
content: `name: Recall OS
|
|
3115
|
+
|
|
3116
|
+
on:
|
|
3117
|
+
push:
|
|
3118
|
+
pull_request:
|
|
3119
|
+
|
|
3120
|
+
jobs:
|
|
3121
|
+
doctor:
|
|
3122
|
+
runs-on: ubuntu-latest
|
|
3123
|
+
steps:
|
|
3124
|
+
- uses: actions/checkout@v4
|
|
3125
|
+
- uses: actions/setup-node@v4
|
|
3126
|
+
with:
|
|
3127
|
+
node-version: 20
|
|
3128
|
+
- name: Validate repository memory
|
|
3129
|
+
run: npx --yes recall-os@latest doctor
|
|
2676
3130
|
`
|
|
2677
3131
|
}
|
|
2678
3132
|
];
|
|
2679
3133
|
function generateInitFiles(options) {
|
|
2680
|
-
const repositoryName =
|
|
3134
|
+
const repositoryName = path13.basename(path13.resolve(options.rootDir)) || "repository";
|
|
2681
3135
|
const context = createTemplateContext({ repositoryName });
|
|
2682
3136
|
const files = neutralTemplates.map((template) => ({
|
|
2683
3137
|
path: template.path,
|
|
@@ -2696,24 +3150,25 @@ function generatePresetFiles(preset) {
|
|
|
2696
3150
|
})),
|
|
2697
3151
|
...preset.proposedDecisions.map((decision) => ({
|
|
2698
3152
|
path: decision.destination,
|
|
2699
|
-
|
|
3153
|
+
// Normalize every preset's proposed ADR so it stays Doctor-healthy once accepted.
|
|
3154
|
+
content: ensureRequiredAdrSections(decision.body)
|
|
2700
3155
|
}))
|
|
2701
3156
|
];
|
|
2702
3157
|
}
|
|
2703
3158
|
|
|
2704
3159
|
// src/core/hooks/detect-gates.ts
|
|
2705
|
-
import { existsSync as
|
|
2706
|
-
import { readFile as
|
|
2707
|
-
import
|
|
3160
|
+
import { existsSync as existsSync5 } from "fs";
|
|
3161
|
+
import { readFile as readFile10 } from "fs/promises";
|
|
3162
|
+
import path14 from "path";
|
|
2708
3163
|
var KNOWN_SCRIPTS = ["test", "typecheck", "lint"];
|
|
2709
3164
|
async function detectPreCommitGates(rootDir) {
|
|
2710
|
-
const packageJsonPath =
|
|
2711
|
-
if (!
|
|
3165
|
+
const packageJsonPath = path14.join(rootDir, "package.json");
|
|
3166
|
+
if (!existsSync5(packageJsonPath)) {
|
|
2712
3167
|
return [];
|
|
2713
3168
|
}
|
|
2714
3169
|
let scripts;
|
|
2715
3170
|
try {
|
|
2716
|
-
const raw = await
|
|
3171
|
+
const raw = await readFile10(packageJsonPath, "utf8");
|
|
2717
3172
|
const parsed = JSON.parse(raw);
|
|
2718
3173
|
scripts = parsed.scripts ?? {};
|
|
2719
3174
|
} catch {
|
|
@@ -2722,16 +3177,16 @@ async function detectPreCommitGates(rootDir) {
|
|
|
2722
3177
|
if (typeof scripts !== "object" || scripts === null) {
|
|
2723
3178
|
return [];
|
|
2724
3179
|
}
|
|
2725
|
-
const packageManager =
|
|
3180
|
+
const packageManager = detectPackageManager2(rootDir);
|
|
2726
3181
|
return KNOWN_SCRIPTS.filter((script) => typeof scripts[script] === "string").map(
|
|
2727
3182
|
(script) => `${packageManager} run ${script}`
|
|
2728
3183
|
);
|
|
2729
3184
|
}
|
|
2730
|
-
function
|
|
2731
|
-
if (
|
|
3185
|
+
function detectPackageManager2(rootDir) {
|
|
3186
|
+
if (existsSync5(path14.join(rootDir, "pnpm-lock.yaml"))) {
|
|
2732
3187
|
return "pnpm";
|
|
2733
3188
|
}
|
|
2734
|
-
if (
|
|
3189
|
+
if (existsSync5(path14.join(rootDir, "yarn.lock"))) {
|
|
2735
3190
|
return "yarn";
|
|
2736
3191
|
}
|
|
2737
3192
|
return "npm";
|
|
@@ -2740,6 +3195,39 @@ function detectPackageManager(rootDir) {
|
|
|
2740
3195
|
// src/core/hooks/generate-hook.ts
|
|
2741
3196
|
var PRE_COMMIT_HOOK_PATH = ".recall/hooks/pre-commit";
|
|
2742
3197
|
var HOOKS_PATH_ACTIVATION_COMMAND = "git config core.hooksPath .recall/hooks";
|
|
3198
|
+
var SESSION_START_HOOK_PATH = ".claude/hooks/session-start.sh";
|
|
3199
|
+
var CLAUDE_SETTINGS_PATH = ".claude/settings.json";
|
|
3200
|
+
function renderSessionStartHook() {
|
|
3201
|
+
return `#!/bin/sh
|
|
3202
|
+
# Recall OS Claude Code SessionStart hook.
|
|
3203
|
+
# Generated by \`recall init\`. Injects a repository-memory map into every Claude Code session so a
|
|
3204
|
+
# fresh agent reliably loads durable memory. Wired in .claude/settings.json. Read-only.
|
|
3205
|
+
|
|
3206
|
+
adrs=$(ls docs/adrs/ADR-*.md 2>/dev/null | sed 's|.*/||;s|\\.md$||' | tr '\\n' ' ')
|
|
3207
|
+
modules=$(ls -d docs/30-modules/*/ 2>/dev/null | sed 's|docs/30-modules/||;s|/$||' | tr '\\n' ' ')
|
|
3208
|
+
|
|
3209
|
+
context="Recall OS repository memory is the source of truth over chat history. Before non-trivial work, read AGENTS.md and the docs it routes to; repository rules override model preference. Accepted ADRs (docs/adrs/): \${adrs:-none yet}. Modules (docs/30-modules/): \${modules:-none yet}. Run 'recall doctor' before claiming work complete."
|
|
3210
|
+
|
|
3211
|
+
printf '{"hookSpecificOutput":{"hookEventName":"SessionStart","additionalContext":"%s"}}\\n' "$context"
|
|
3212
|
+
`;
|
|
3213
|
+
}
|
|
3214
|
+
function renderClaudeSettings() {
|
|
3215
|
+
return `${JSON.stringify(
|
|
3216
|
+
{
|
|
3217
|
+
hooks: {
|
|
3218
|
+
SessionStart: [
|
|
3219
|
+
{
|
|
3220
|
+
matcher: "startup",
|
|
3221
|
+
hooks: [{ type: "command", command: `./${SESSION_START_HOOK_PATH}` }]
|
|
3222
|
+
}
|
|
3223
|
+
]
|
|
3224
|
+
}
|
|
3225
|
+
},
|
|
3226
|
+
null,
|
|
3227
|
+
2
|
|
3228
|
+
)}
|
|
3229
|
+
`;
|
|
3230
|
+
}
|
|
2743
3231
|
function renderPreCommitHook(gates) {
|
|
2744
3232
|
const lines = [
|
|
2745
3233
|
"#!/bin/sh",
|
|
@@ -3251,73 +3739,129 @@ Consider MVVM with unidirectional state from ViewModels, awaiting human acceptan
|
|
|
3251
3739
|
]
|
|
3252
3740
|
};
|
|
3253
3741
|
|
|
3254
|
-
// src/presets/
|
|
3255
|
-
var
|
|
3742
|
+
// src/presets/laravel/shared.ts
|
|
3743
|
+
var VARIANTS = {
|
|
3744
|
+
react: {
|
|
3745
|
+
id: "laravel-react",
|
|
3746
|
+
label: "React via Inertia",
|
|
3747
|
+
description: "Opinionated Laravel + Inertia + React opinion pack (proposed decisions only). Matches the official Laravel React starter kit.",
|
|
3748
|
+
frontendLine: "Frontend: Inertia 2 + React 19 + TypeScript + Tailwind, built with Vite (the official React starter kit, with shadcn/ui for components).",
|
|
3749
|
+
deliveryLine: "The app is a server-driven SPA: Laravel controllers return Inertia responses with typed props; there is no separate REST client for first-party screens."
|
|
3750
|
+
},
|
|
3751
|
+
vue: {
|
|
3752
|
+
id: "laravel-vue",
|
|
3753
|
+
label: "Vue via Inertia",
|
|
3754
|
+
description: "Opinionated Laravel + Inertia + Vue opinion pack (proposed decisions only). Matches the official Laravel Vue starter kit.",
|
|
3755
|
+
frontendLine: "Frontend: Inertia 2 + Vue 3 (script setup) + TypeScript + Tailwind, built with Vite (the official Vue starter kit).",
|
|
3756
|
+
deliveryLine: "The app is a server-driven SPA: Laravel controllers return Inertia responses with typed props; there is no separate REST client for first-party screens."
|
|
3757
|
+
},
|
|
3758
|
+
api: {
|
|
3759
|
+
id: "laravel-api",
|
|
3760
|
+
label: "API / SPA backend",
|
|
3761
|
+
description: "Opinionated Laravel API-only opinion pack (proposed decisions only) for a decoupled SPA or mobile client.",
|
|
3762
|
+
frontendLine: "No server-rendered frontend: Laravel is an HTTP JSON API consumed by a separate SPA or mobile app.",
|
|
3763
|
+
deliveryLine: "Controllers return JSON via API Resources; first-party SPAs authenticate with Sanctum cookies, mobile clients with Sanctum tokens."
|
|
3764
|
+
}
|
|
3765
|
+
};
|
|
3766
|
+
function adr(presetId, topic, title, body) {
|
|
3767
|
+
return {
|
|
3768
|
+
id: `${presetId}-${topic}`,
|
|
3769
|
+
title,
|
|
3770
|
+
status: "proposed",
|
|
3771
|
+
destination: `docs/adrs/proposed/ADR-PROPOSED-${presetId}-${topic}.md`,
|
|
3772
|
+
body
|
|
3773
|
+
};
|
|
3774
|
+
}
|
|
3775
|
+
function related(presetId, ...extra) {
|
|
3776
|
+
return [
|
|
3777
|
+
`## Related Documents`,
|
|
3778
|
+
``,
|
|
3779
|
+
`- \`docs/ai/presets/${presetId}-guidance.md\` \u2014 the proposed Laravel stack guidance.`,
|
|
3780
|
+
`- \`docs/10-architecture/ARCHITECTURE.md\` \u2014 record the accepted architecture here once promoted.`,
|
|
3781
|
+
...extra.map((line) => `- ${line}`),
|
|
3782
|
+
``
|
|
3783
|
+
].join("\n");
|
|
3784
|
+
}
|
|
3785
|
+
function laravelGuidance(variant) {
|
|
3786
|
+
const profile = VARIANTS[variant];
|
|
3787
|
+
return `# Laravel Preset Guidance (${profile.label})
|
|
3256
3788
|
|
|
3257
3789
|
This is proposed guidance, not accepted. Convert any architecture choice into a proposed ADR, then an
|
|
3258
|
-
accepted ADR, before treating it as repository truth.
|
|
3790
|
+
accepted ADR, before treating it as repository truth. Repository rules override model preference.
|
|
3791
|
+
|
|
3792
|
+
## The stack (proposed)
|
|
3793
|
+
|
|
3794
|
+
- Laravel 12 on PHP 8.3+, using the official conventions and directory layout.
|
|
3795
|
+
- ${profile.frontendLine}
|
|
3796
|
+
- Database: PostgreSQL (MySQL is the alternative) through Eloquent and migrations.
|
|
3797
|
+
- Auth: Laravel Sanctum for first-party SPA and mobile clients (Passport only if you need third-party OAuth2).
|
|
3798
|
+
- Background work: queues, with Redis and Laravel Horizon when throughput grows.
|
|
3799
|
+
- Tests: Pest, with database factories and feature tests over real routes.
|
|
3800
|
+
|
|
3801
|
+
${profile.deliveryLine}
|
|
3259
3802
|
|
|
3260
3803
|
## Decision forks this stack forces
|
|
3261
3804
|
|
|
3262
|
-
-
|
|
3263
|
-
-
|
|
3264
|
-
-
|
|
3265
|
-
-
|
|
3266
|
-
-
|
|
3805
|
+
- Frontend delivery: Inertia (server-driven SPA) vs a decoupled API + separate SPA vs Blade + Livewire.
|
|
3806
|
+
- Auth: Sanctum (first-party SPA and mobile) vs Passport (third-party OAuth2) vs a managed identity provider.
|
|
3807
|
+
- Database: PostgreSQL vs MySQL, and where read scaling and queues live (Redis vs database driver).
|
|
3808
|
+
- Authorization: Policies and Gates vs ad-hoc checks; validation via Form Requests vs inline.
|
|
3809
|
+
- Business logic: thin controllers with Action/Service classes vs fat controllers and models.
|
|
3810
|
+
- Testing: Pest vs PHPUnit.
|
|
3267
3811
|
|
|
3268
3812
|
## Recommended structure (proposed)
|
|
3269
3813
|
|
|
3270
|
-
-
|
|
3271
|
-
-
|
|
3272
|
-
-
|
|
3814
|
+
- Keep controllers thin: they validate, authorize, delegate, and return a response \u2014 nothing more.
|
|
3815
|
+
- Put request validation **and** authorization in Form Requests (\`authorize()\` + \`rules()\`).
|
|
3816
|
+
- Put per-model and per-action permission logic in Policies and Gates, not in controllers.
|
|
3817
|
+
- Put business logic in single-purpose Action or Service classes, not in controllers or models.
|
|
3818
|
+
- Shape every outbound payload with API Resources (or typed Inertia props), never raw models.
|
|
3819
|
+
- Declare \`$fillable\` (or \`$guarded\`) explicitly on every Eloquent model to stop mass assignment.
|
|
3820
|
+
|
|
3821
|
+
## Data and performance (proposed)
|
|
3822
|
+
|
|
3823
|
+
- Eager-load relationships (\`with(...)\`) to avoid N+1 queries; enable \`Model::preventLazyLoading()\` in local and CI.
|
|
3824
|
+
- Wrap multi-write operations in database transactions.
|
|
3825
|
+
- Paginate list endpoints; never return unbounded collections.
|
|
3826
|
+
- Move email, exports, third-party calls, and other slow work into queued jobs.
|
|
3827
|
+
- Cache expensive reads deliberately, with explicit invalidation.
|
|
3273
3828
|
|
|
3274
3829
|
## Testing (proposed)
|
|
3275
3830
|
|
|
3276
|
-
-
|
|
3277
|
-
-
|
|
3278
|
-
-
|
|
3831
|
+
- Write Pest feature tests that exercise real routes end to end, using \`RefreshDatabase\`.
|
|
3832
|
+
- Build state with model factories, not hand-rolled fixtures.
|
|
3833
|
+
- Test authorization explicitly: a forbidden action must assert a 403, not just a happy path.
|
|
3834
|
+
- Cover validation failures, not only the success case.
|
|
3279
3835
|
|
|
3280
3836
|
## Security considerations (proposed)
|
|
3281
3837
|
|
|
3282
|
-
-
|
|
3283
|
-
-
|
|
3284
|
-
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
id: `nextjs-${topic}`,
|
|
3289
|
-
title,
|
|
3290
|
-
status: "proposed",
|
|
3291
|
-
destination: `docs/adrs/proposed/ADR-PROPOSED-nextjs-${topic}.md`,
|
|
3292
|
-
body
|
|
3293
|
-
};
|
|
3838
|
+
- Validate every inbound request through Form Requests; persist only validated data.
|
|
3839
|
+
- Authorize every state-changing action through a Policy or Gate.
|
|
3840
|
+
- Keep secrets in \`.env\`; never commit \`.env\` or hardcode credentials.
|
|
3841
|
+
- Apply rate limiting to auth and write endpoints.
|
|
3842
|
+
- Keep mass assignment locked down and never trust client-supplied IDs without an ownership check.
|
|
3843
|
+
${variant === "api" ? "- Scope Sanctum tokens to least privilege; SPA clients use the cookie guard with CSRF protection.\n" : "- Inertia uses Laravel's session and CSRF protection; keep auth and authorization on the server, never the client.\n"}`;
|
|
3294
3844
|
}
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
name: "Next.js",
|
|
3298
|
-
description: "Opinionated Next.js opinion pack with proposed decisions only.",
|
|
3299
|
-
templates: [
|
|
3300
|
-
{
|
|
3301
|
-
destination: "docs/ai/presets/nextjs-guidance.md",
|
|
3302
|
-
description: "Next.js guidance that remains proposed until accepted.",
|
|
3303
|
-
content: guidance3
|
|
3304
|
-
}
|
|
3305
|
-
],
|
|
3306
|
-
guidance: [
|
|
3845
|
+
function laravelGuidanceItems() {
|
|
3846
|
+
return [
|
|
3307
3847
|
{
|
|
3308
|
-
title: "Keep
|
|
3309
|
-
body: "
|
|
3848
|
+
title: "Keep stack choices proposed",
|
|
3849
|
+
body: "Framework, frontend delivery, database, auth, and testing choices stay proposed until accepted in repository memory."
|
|
3310
3850
|
},
|
|
3311
3851
|
{
|
|
3312
|
-
title: "
|
|
3313
|
-
body: "
|
|
3852
|
+
title: "Thin controllers, explicit authorization",
|
|
3853
|
+
body: "Validate and authorize in Form Requests and Policies, keep business logic in Action or Service classes, and shape output with Resources \u2014 propose these as decisions before treating them as truth."
|
|
3314
3854
|
}
|
|
3315
|
-
]
|
|
3316
|
-
|
|
3317
|
-
|
|
3855
|
+
];
|
|
3856
|
+
}
|
|
3857
|
+
function laravelProposedDecisions(variant) {
|
|
3858
|
+
const presetId = VARIANTS[variant].id;
|
|
3859
|
+
const base = [
|
|
3860
|
+
adr(
|
|
3861
|
+
presetId,
|
|
3318
3862
|
"framework",
|
|
3319
|
-
"Use
|
|
3320
|
-
`# Proposed ADR: Use
|
|
3863
|
+
"Use Laravel",
|
|
3864
|
+
`# Proposed ADR: Use Laravel
|
|
3321
3865
|
|
|
3322
3866
|
## Status
|
|
3323
3867
|
|
|
@@ -3325,28 +3869,30 @@ Proposed
|
|
|
3325
3869
|
|
|
3326
3870
|
## Context
|
|
3327
3871
|
|
|
3328
|
-
The team needs a
|
|
3872
|
+
The team needs a productive, batteries-included PHP framework for a production web application.
|
|
3329
3873
|
|
|
3330
3874
|
## Decision
|
|
3331
3875
|
|
|
3332
|
-
Consider
|
|
3333
|
-
it.
|
|
3876
|
+
Consider Laravel 12 on PHP 8.3+ as the application framework, following its standard conventions and
|
|
3877
|
+
directory structure. This is not accepted until a human reviews and accepts it.
|
|
3334
3878
|
|
|
3335
3879
|
## Alternatives Considered
|
|
3336
3880
|
|
|
3337
|
-
-
|
|
3338
|
-
-
|
|
3881
|
+
- Symfony for a more component-assembled approach.
|
|
3882
|
+
- A different language or framework entirely.
|
|
3339
3883
|
|
|
3340
3884
|
## Consequences
|
|
3341
3885
|
|
|
3342
|
-
-
|
|
3343
|
-
- Couples the
|
|
3344
|
-
|
|
3886
|
+
- A mature ecosystem (Eloquent, queues, Sanctum, Horizon) and strong conventions.
|
|
3887
|
+
- Couples the application to Laravel's conventions and release cadence.
|
|
3888
|
+
|
|
3889
|
+
${related(presetId)}`
|
|
3345
3890
|
),
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
"
|
|
3349
|
-
|
|
3891
|
+
adr(
|
|
3892
|
+
presetId,
|
|
3893
|
+
"database-eloquent",
|
|
3894
|
+
"Use Eloquent and migrations on PostgreSQL",
|
|
3895
|
+
`# Proposed ADR: Use Eloquent and migrations on PostgreSQL
|
|
3350
3896
|
|
|
3351
3897
|
## Status
|
|
3352
3898
|
|
|
@@ -3354,27 +3900,30 @@ Proposed
|
|
|
3354
3900
|
|
|
3355
3901
|
## Context
|
|
3356
3902
|
|
|
3357
|
-
|
|
3903
|
+
The application needs a relational database and a schema workflow.
|
|
3358
3904
|
|
|
3359
3905
|
## Decision
|
|
3360
3906
|
|
|
3361
|
-
Consider the
|
|
3907
|
+
Consider PostgreSQL (MySQL as the alternative) accessed through Eloquent and versioned migrations,
|
|
3908
|
+
awaiting human acceptance.
|
|
3362
3909
|
|
|
3363
3910
|
## Alternatives Considered
|
|
3364
3911
|
|
|
3365
|
-
-
|
|
3366
|
-
-
|
|
3912
|
+
- MySQL or MariaDB.
|
|
3913
|
+
- The query builder or raw SQL without Eloquent.
|
|
3367
3914
|
|
|
3368
3915
|
## Consequences
|
|
3369
3916
|
|
|
3370
|
-
-
|
|
3371
|
-
- Requires
|
|
3372
|
-
|
|
3917
|
+
- Expressive models, relationships, and reproducible schema migrations.
|
|
3918
|
+
- Requires discipline against N+1 queries and unbounded result sets.
|
|
3919
|
+
|
|
3920
|
+
${related(presetId, "`docs/50-quality/TESTING_STRATEGY.md` \u2014 how database tests use factories and a disposable database.")}`
|
|
3373
3921
|
),
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
"
|
|
3377
|
-
|
|
3922
|
+
adr(
|
|
3923
|
+
presetId,
|
|
3924
|
+
"auth-sanctum",
|
|
3925
|
+
"Use Laravel Sanctum for authentication",
|
|
3926
|
+
`# Proposed ADR: Use Laravel Sanctum for authentication
|
|
3378
3927
|
|
|
3379
3928
|
## Status
|
|
3380
3929
|
|
|
@@ -3382,27 +3931,30 @@ Proposed
|
|
|
3382
3931
|
|
|
3383
3932
|
## Context
|
|
3384
3933
|
|
|
3385
|
-
The
|
|
3934
|
+
The application needs authentication for first-party clients (${variant === "api" ? "a separate SPA and mobile apps" : "an Inertia SPA, and possibly mobile apps"}).
|
|
3386
3935
|
|
|
3387
3936
|
## Decision
|
|
3388
3937
|
|
|
3389
|
-
Consider
|
|
3938
|
+
Consider Laravel Sanctum: the cookie-based guard for first-party SPAs and API tokens for mobile or
|
|
3939
|
+
scripted clients. This is not accepted until a human reviews and accepts it.
|
|
3390
3940
|
|
|
3391
3941
|
## Alternatives Considered
|
|
3392
3942
|
|
|
3393
|
-
-
|
|
3394
|
-
-
|
|
3943
|
+
- Laravel Passport for full OAuth2 (third-party delegated access).
|
|
3944
|
+
- A managed identity provider.
|
|
3395
3945
|
|
|
3396
3946
|
## Consequences
|
|
3397
3947
|
|
|
3398
|
-
-
|
|
3399
|
-
-
|
|
3400
|
-
|
|
3948
|
+
- Lightweight first-party auth without standing up a full OAuth2 server.
|
|
3949
|
+
- If third-party delegated access is ever required, revisit with Passport.
|
|
3950
|
+
|
|
3951
|
+
${related(presetId, "`docs/20-security/SECURITY_MODEL.md` \u2014 record the accepted auth and session model here.")}`
|
|
3401
3952
|
),
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
"
|
|
3405
|
-
|
|
3953
|
+
adr(
|
|
3954
|
+
presetId,
|
|
3955
|
+
"validation-authorization",
|
|
3956
|
+
"Validate with Form Requests and authorize with Policies",
|
|
3957
|
+
`# Proposed ADR: Validate with Form Requests and authorize with Policies
|
|
3406
3958
|
|
|
3407
3959
|
## Status
|
|
3408
3960
|
|
|
@@ -3410,27 +3962,31 @@ Proposed
|
|
|
3410
3962
|
|
|
3411
3963
|
## Context
|
|
3412
3964
|
|
|
3413
|
-
|
|
3965
|
+
Input validation and authorization must be consistent and centralized, not scattered across
|
|
3966
|
+
controllers.
|
|
3414
3967
|
|
|
3415
3968
|
## Decision
|
|
3416
3969
|
|
|
3417
|
-
Consider
|
|
3970
|
+
Consider Form Requests for validation (and request-level authorization) plus Policies and Gates for
|
|
3971
|
+
per-model and per-action permission checks, awaiting human acceptance.
|
|
3418
3972
|
|
|
3419
3973
|
## Alternatives Considered
|
|
3420
3974
|
|
|
3421
|
-
-
|
|
3422
|
-
- A
|
|
3975
|
+
- Inline validation and authorization in controllers.
|
|
3976
|
+
- A third-party permissions package layered on top.
|
|
3423
3977
|
|
|
3424
3978
|
## Consequences
|
|
3425
3979
|
|
|
3426
|
-
-
|
|
3427
|
-
-
|
|
3428
|
-
|
|
3980
|
+
- Controllers stay thin; validation and authorization are testable in isolation.
|
|
3981
|
+
- Every state-changing action must have an explicit authorization path.
|
|
3982
|
+
|
|
3983
|
+
${related(presetId)}`
|
|
3429
3984
|
),
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
"
|
|
3433
|
-
|
|
3985
|
+
adr(
|
|
3986
|
+
presetId,
|
|
3987
|
+
"application-structure",
|
|
3988
|
+
"Keep controllers thin with Action and Service classes",
|
|
3989
|
+
`# Proposed ADR: Keep controllers thin with Action and Service classes
|
|
3434
3990
|
|
|
3435
3991
|
## Status
|
|
3436
3992
|
|
|
@@ -3438,93 +3994,278 @@ Proposed
|
|
|
3438
3994
|
|
|
3439
3995
|
## Context
|
|
3440
3996
|
|
|
3441
|
-
|
|
3997
|
+
Business logic tends to accumulate in controllers and models, which makes it hard to test and reuse.
|
|
3442
3998
|
|
|
3443
3999
|
## Decision
|
|
3444
4000
|
|
|
3445
|
-
Consider
|
|
4001
|
+
Consider thin controllers that delegate to single-purpose Action or Service classes, with outbound
|
|
4002
|
+
payloads shaped by API Resources (or typed Inertia props). This is not accepted until a human accepts
|
|
4003
|
+
it.
|
|
3446
4004
|
|
|
3447
4005
|
## Alternatives Considered
|
|
3448
4006
|
|
|
3449
|
-
-
|
|
3450
|
-
-
|
|
4007
|
+
- Fat controllers.
|
|
4008
|
+
- Fat models holding business logic.
|
|
3451
4009
|
|
|
3452
4010
|
## Consequences
|
|
3453
4011
|
|
|
3454
|
-
-
|
|
3455
|
-
-
|
|
3456
|
-
|
|
4012
|
+
- Reusable, unit-testable business logic and consistent response shapes.
|
|
4013
|
+
- More classes and a convention the team must follow.
|
|
4014
|
+
|
|
4015
|
+
${related(presetId)}`
|
|
4016
|
+
),
|
|
4017
|
+
adr(
|
|
4018
|
+
presetId,
|
|
4019
|
+
"queues-horizon",
|
|
4020
|
+
"Run slow work on queues",
|
|
4021
|
+
`# Proposed ADR: Run slow work on queues
|
|
4022
|
+
|
|
4023
|
+
## Status
|
|
4024
|
+
|
|
4025
|
+
Proposed
|
|
4026
|
+
|
|
4027
|
+
## Context
|
|
4028
|
+
|
|
4029
|
+
Email, exports, and third-party calls slow down requests and can fail independently.
|
|
4030
|
+
|
|
4031
|
+
## Decision
|
|
4032
|
+
|
|
4033
|
+
Consider queued jobs for slow or failure-prone work, using the database driver early and Redis with
|
|
4034
|
+
Laravel Horizon as throughput grows. This is not accepted until a human reviews and accepts it.
|
|
4035
|
+
|
|
4036
|
+
## Alternatives Considered
|
|
4037
|
+
|
|
4038
|
+
- Doing the work synchronously in the request.
|
|
4039
|
+
- An external task queue or serverless functions.
|
|
4040
|
+
|
|
4041
|
+
## Consequences
|
|
4042
|
+
|
|
4043
|
+
- Faster responses and isolated, retryable background work.
|
|
4044
|
+
- Adds a worker process and queue infrastructure to operate and monitor.
|
|
4045
|
+
|
|
4046
|
+
${related(presetId)}`
|
|
4047
|
+
),
|
|
4048
|
+
adr(
|
|
4049
|
+
presetId,
|
|
4050
|
+
"testing-pest",
|
|
4051
|
+
"Use Pest for testing",
|
|
4052
|
+
`# Proposed ADR: Use Pest for testing
|
|
4053
|
+
|
|
4054
|
+
## Status
|
|
4055
|
+
|
|
4056
|
+
Proposed
|
|
4057
|
+
|
|
4058
|
+
## Context
|
|
4059
|
+
|
|
4060
|
+
The application needs a fast, readable testing workflow.
|
|
4061
|
+
|
|
4062
|
+
## Decision
|
|
4063
|
+
|
|
4064
|
+
Consider Pest with model factories and feature tests that exercise real routes against a disposable
|
|
4065
|
+
database, awaiting human acceptance.
|
|
4066
|
+
|
|
4067
|
+
## Alternatives Considered
|
|
4068
|
+
|
|
4069
|
+
- PHPUnit directly.
|
|
4070
|
+
- A thinner test suite focused only on unit tests.
|
|
4071
|
+
|
|
4072
|
+
## Consequences
|
|
4073
|
+
|
|
4074
|
+
- Concise, expressive tests that cover routes, validation, and authorization.
|
|
4075
|
+
- The team standardizes on Pest's syntax and plugins.
|
|
4076
|
+
|
|
4077
|
+
${related(presetId, "`docs/50-quality/TESTING_STRATEGY.md` \u2014 record the accepted testing approach here.")}`
|
|
3457
4078
|
)
|
|
3458
|
-
]
|
|
4079
|
+
];
|
|
4080
|
+
return [...base, frontendDecision(variant)];
|
|
4081
|
+
}
|
|
4082
|
+
function frontendDecision(variant) {
|
|
4083
|
+
const presetId = VARIANTS[variant].id;
|
|
4084
|
+
if (variant === "api") {
|
|
4085
|
+
return adr(
|
|
4086
|
+
presetId,
|
|
4087
|
+
"api-design-rest",
|
|
4088
|
+
"Expose a versioned REST API with API Resources",
|
|
4089
|
+
`# Proposed ADR: Expose a versioned REST API with API Resources
|
|
4090
|
+
|
|
4091
|
+
## Status
|
|
4092
|
+
|
|
4093
|
+
Proposed
|
|
4094
|
+
|
|
4095
|
+
## Context
|
|
4096
|
+
|
|
4097
|
+
A decoupled SPA or mobile client consumes Laravel over HTTP, so the API contract must be stable and
|
|
4098
|
+
explicit.
|
|
4099
|
+
|
|
4100
|
+
## Decision
|
|
4101
|
+
|
|
4102
|
+
Consider a versioned REST API (for example \`/api/v1\`) whose responses are shaped by API Resources,
|
|
4103
|
+
authenticated with Sanctum, and documented (OpenAPI). This is not accepted until a human accepts it.
|
|
4104
|
+
|
|
4105
|
+
## Alternatives Considered
|
|
4106
|
+
|
|
4107
|
+
- GraphQL.
|
|
4108
|
+
- Server-driven Inertia pages instead of a decoupled API.
|
|
4109
|
+
|
|
4110
|
+
## Consequences
|
|
4111
|
+
|
|
4112
|
+
- A stable, documented contract that multiple clients can rely on.
|
|
4113
|
+
- Versioning and serialization become an explicit, maintained concern.
|
|
4114
|
+
|
|
4115
|
+
${related(presetId, "`docs/20-security/SECURITY_MODEL.md` \u2014 record token scopes and the SPA cookie guard here.")}`
|
|
4116
|
+
);
|
|
4117
|
+
}
|
|
4118
|
+
const framework = variant === "react" ? "React 19" : "Vue 3";
|
|
4119
|
+
const components = variant === "react" ? "shadcn/ui components on Tailwind" : "Tailwind with single-file components (script setup)";
|
|
4120
|
+
return adr(
|
|
4121
|
+
presetId,
|
|
4122
|
+
`frontend-inertia-${variant}`,
|
|
4123
|
+
`Use Inertia with ${framework}`,
|
|
4124
|
+
`# Proposed ADR: Use Inertia with ${framework}
|
|
4125
|
+
|
|
4126
|
+
## Status
|
|
4127
|
+
|
|
4128
|
+
Proposed
|
|
4129
|
+
|
|
4130
|
+
## Context
|
|
4131
|
+
|
|
4132
|
+
The application needs a modern SPA experience without standing up and securing a separate API for
|
|
4133
|
+
first-party screens.
|
|
4134
|
+
|
|
4135
|
+
## Decision
|
|
4136
|
+
|
|
4137
|
+
Consider Inertia 2 with ${framework} and TypeScript, built with Vite, using ${components}. Controllers
|
|
4138
|
+
return Inertia responses with typed props. This is not accepted until a human reviews and accepts it.
|
|
4139
|
+
|
|
4140
|
+
## Alternatives Considered
|
|
4141
|
+
|
|
4142
|
+
- A decoupled REST or GraphQL API with a standalone SPA.
|
|
4143
|
+
- Blade with Livewire.
|
|
4144
|
+
|
|
4145
|
+
## Consequences
|
|
4146
|
+
|
|
4147
|
+
- Server-driven routing and auth with a reactive ${framework} frontend and no duplicate API layer.
|
|
4148
|
+
- Couples the frontend to Inertia's model and the ${framework} ecosystem.
|
|
4149
|
+
|
|
4150
|
+
${related(presetId)}`
|
|
4151
|
+
);
|
|
4152
|
+
}
|
|
4153
|
+
|
|
4154
|
+
// src/presets/laravel-api/preset.ts
|
|
4155
|
+
var laravelApiPreset = {
|
|
4156
|
+
id: "laravel-api",
|
|
4157
|
+
name: "Laravel API",
|
|
4158
|
+
description: "Opinionated Laravel API-only opinion pack with proposed decisions only.",
|
|
4159
|
+
templates: [
|
|
4160
|
+
{
|
|
4161
|
+
destination: "docs/ai/presets/laravel-api-guidance.md",
|
|
4162
|
+
description: "Laravel API-only guidance that remains proposed until accepted.",
|
|
4163
|
+
content: laravelGuidance("api")
|
|
4164
|
+
}
|
|
4165
|
+
],
|
|
4166
|
+
guidance: laravelGuidanceItems(),
|
|
4167
|
+
proposedDecisions: laravelProposedDecisions("api")
|
|
3459
4168
|
};
|
|
3460
4169
|
|
|
3461
|
-
// src/presets/
|
|
3462
|
-
var
|
|
4170
|
+
// src/presets/laravel-react/preset.ts
|
|
4171
|
+
var laravelReactPreset = {
|
|
4172
|
+
id: "laravel-react",
|
|
4173
|
+
name: "Laravel + React",
|
|
4174
|
+
description: "Opinionated Laravel + Inertia + React opinion pack with proposed decisions only.",
|
|
4175
|
+
templates: [
|
|
4176
|
+
{
|
|
4177
|
+
destination: "docs/ai/presets/laravel-react-guidance.md",
|
|
4178
|
+
description: "Laravel + React (Inertia) guidance that remains proposed until accepted.",
|
|
4179
|
+
content: laravelGuidance("react")
|
|
4180
|
+
}
|
|
4181
|
+
],
|
|
4182
|
+
guidance: laravelGuidanceItems(),
|
|
4183
|
+
proposedDecisions: laravelProposedDecisions("react")
|
|
4184
|
+
};
|
|
3463
4185
|
|
|
3464
|
-
|
|
3465
|
-
|
|
4186
|
+
// src/presets/laravel-vue/preset.ts
|
|
4187
|
+
var laravelVuePreset = {
|
|
4188
|
+
id: "laravel-vue",
|
|
4189
|
+
name: "Laravel + Vue",
|
|
4190
|
+
description: "Opinionated Laravel + Inertia + Vue opinion pack with proposed decisions only.",
|
|
4191
|
+
templates: [
|
|
4192
|
+
{
|
|
4193
|
+
destination: "docs/ai/presets/laravel-vue-guidance.md",
|
|
4194
|
+
description: "Laravel + Vue (Inertia) guidance that remains proposed until accepted.",
|
|
4195
|
+
content: laravelGuidance("vue")
|
|
4196
|
+
}
|
|
4197
|
+
],
|
|
4198
|
+
guidance: laravelGuidanceItems(),
|
|
4199
|
+
proposedDecisions: laravelProposedDecisions("vue")
|
|
4200
|
+
};
|
|
4201
|
+
|
|
4202
|
+
// src/presets/nextjs/preset.ts
|
|
4203
|
+
var guidance3 = `# Next.js Preset Guidance
|
|
4204
|
+
|
|
4205
|
+
This is proposed guidance, not accepted. Convert any architecture choice into a proposed ADR, then an
|
|
4206
|
+
accepted ADR, before treating it as repository truth.
|
|
3466
4207
|
|
|
3467
4208
|
## Decision forks this stack forces
|
|
3468
4209
|
|
|
3469
|
-
-
|
|
3470
|
-
-
|
|
3471
|
-
-
|
|
3472
|
-
-
|
|
3473
|
-
-
|
|
4210
|
+
- Routing: App Router vs Pages Router.
|
|
4211
|
+
- Rendering: Server Components and server actions vs client-heavy rendering.
|
|
4212
|
+
- Data layer: Drizzle or Prisma with PostgreSQL vs a hosted backend.
|
|
4213
|
+
- Styling: Tailwind CSS vs CSS Modules vs a component library.
|
|
4214
|
+
- Testing: Vitest with Testing Library and Playwright vs other runners.
|
|
3474
4215
|
|
|
3475
4216
|
## Recommended structure (proposed)
|
|
3476
4217
|
|
|
3477
|
-
-
|
|
3478
|
-
-
|
|
3479
|
-
-
|
|
4218
|
+
- The App Router with route groups and colocated server components.
|
|
4219
|
+
- A typed data layer isolated from UI components.
|
|
4220
|
+
- Shared UI primitives and a consistent styling system.
|
|
3480
4221
|
|
|
3481
4222
|
## Testing (proposed)
|
|
3482
4223
|
|
|
3483
|
-
-
|
|
3484
|
-
-
|
|
3485
|
-
-
|
|
4224
|
+
- Unit and component tests with Vitest and Testing Library.
|
|
4225
|
+
- End-to-end tests with Playwright for critical flows.
|
|
4226
|
+
- Type-safe data access tested against a disposable database.
|
|
3486
4227
|
|
|
3487
4228
|
## Security considerations (proposed)
|
|
3488
4229
|
|
|
3489
|
-
-
|
|
3490
|
-
- Validate
|
|
3491
|
-
- Scope authentication and authorization
|
|
4230
|
+
- Keep secrets in server-only environment variables, never in client bundles.
|
|
4231
|
+
- Validate input on the server, including server actions and route handlers.
|
|
4232
|
+
- Scope authentication and authorization on the server, not the client.
|
|
3492
4233
|
`;
|
|
3493
|
-
function
|
|
4234
|
+
function proposedAdr3(topic, title, body) {
|
|
3494
4235
|
return {
|
|
3495
|
-
id: `
|
|
4236
|
+
id: `nextjs-${topic}`,
|
|
3496
4237
|
title,
|
|
3497
4238
|
status: "proposed",
|
|
3498
|
-
destination: `docs/adrs/proposed/ADR-PROPOSED-
|
|
4239
|
+
destination: `docs/adrs/proposed/ADR-PROPOSED-nextjs-${topic}.md`,
|
|
3499
4240
|
body
|
|
3500
4241
|
};
|
|
3501
4242
|
}
|
|
3502
|
-
var
|
|
3503
|
-
id: "
|
|
3504
|
-
name: "
|
|
3505
|
-
description: "Opinionated
|
|
4243
|
+
var nextjsPreset = {
|
|
4244
|
+
id: "nextjs",
|
|
4245
|
+
name: "Next.js",
|
|
4246
|
+
description: "Opinionated Next.js opinion pack with proposed decisions only.",
|
|
3506
4247
|
templates: [
|
|
3507
4248
|
{
|
|
3508
|
-
destination: "docs/ai/presets/
|
|
3509
|
-
description: "
|
|
3510
|
-
content:
|
|
4249
|
+
destination: "docs/ai/presets/nextjs-guidance.md",
|
|
4250
|
+
description: "Next.js guidance that remains proposed until accepted.",
|
|
4251
|
+
content: guidance3
|
|
3511
4252
|
}
|
|
3512
4253
|
],
|
|
3513
4254
|
guidance: [
|
|
3514
4255
|
{
|
|
3515
|
-
title: "Keep framework
|
|
3516
|
-
body: "
|
|
4256
|
+
title: "Keep framework choices proposed",
|
|
4257
|
+
body: "Routing, rendering, data layer, styling, and testing choices must remain proposed until accepted in repository memory."
|
|
3517
4258
|
},
|
|
3518
4259
|
{
|
|
3519
|
-
title: "
|
|
3520
|
-
body: "
|
|
4260
|
+
title: "Keep secrets server-side",
|
|
4261
|
+
body: "Never expose secrets to the client bundle, and record the data and auth approach as proposed decisions before acceptance."
|
|
3521
4262
|
}
|
|
3522
4263
|
],
|
|
3523
4264
|
proposedDecisions: [
|
|
3524
|
-
|
|
4265
|
+
proposedAdr3(
|
|
3525
4266
|
"framework",
|
|
3526
|
-
"Use
|
|
3527
|
-
`# Proposed ADR: Use
|
|
4267
|
+
"Use Next.js",
|
|
4268
|
+
`# Proposed ADR: Use Next.js
|
|
3528
4269
|
|
|
3529
4270
|
## Status
|
|
3530
4271
|
|
|
@@ -3532,27 +4273,28 @@ Proposed
|
|
|
3532
4273
|
|
|
3533
4274
|
## Context
|
|
3534
4275
|
|
|
3535
|
-
The
|
|
4276
|
+
The team needs a React framework for a production web application.
|
|
3536
4277
|
|
|
3537
4278
|
## Decision
|
|
3538
4279
|
|
|
3539
|
-
Consider
|
|
4280
|
+
Consider Next.js as the application framework. This is not accepted until a human reviews and accepts
|
|
4281
|
+
it.
|
|
3540
4282
|
|
|
3541
4283
|
## Alternatives Considered
|
|
3542
4284
|
|
|
3543
|
-
-
|
|
3544
|
-
-
|
|
4285
|
+
- A Vite single-page app with a separate API.
|
|
4286
|
+
- Remix or another framework.
|
|
3545
4287
|
|
|
3546
4288
|
## Consequences
|
|
3547
4289
|
|
|
3548
|
-
-
|
|
3549
|
-
-
|
|
4290
|
+
- Server rendering, routing, and a large ecosystem.
|
|
4291
|
+
- Couples the app to Next.js conventions.
|
|
3550
4292
|
`
|
|
3551
4293
|
),
|
|
3552
|
-
|
|
3553
|
-
"
|
|
3554
|
-
"Use
|
|
3555
|
-
`# Proposed ADR: Use
|
|
4294
|
+
proposedAdr3(
|
|
4295
|
+
"routing-app-router",
|
|
4296
|
+
"Use the App Router",
|
|
4297
|
+
`# Proposed ADR: Use the App Router
|
|
3556
4298
|
|
|
3557
4299
|
## Status
|
|
3558
4300
|
|
|
@@ -3560,27 +4302,27 @@ Proposed
|
|
|
3560
4302
|
|
|
3561
4303
|
## Context
|
|
3562
4304
|
|
|
3563
|
-
|
|
4305
|
+
Next.js offers the App Router and the legacy Pages Router.
|
|
3564
4306
|
|
|
3565
4307
|
## Decision
|
|
3566
4308
|
|
|
3567
|
-
Consider
|
|
4309
|
+
Consider the App Router with Server Components, awaiting human acceptance.
|
|
3568
4310
|
|
|
3569
4311
|
## Alternatives Considered
|
|
3570
4312
|
|
|
3571
|
-
-
|
|
3572
|
-
-
|
|
4313
|
+
- The Pages Router.
|
|
4314
|
+
- A mix during migration.
|
|
3573
4315
|
|
|
3574
4316
|
## Consequences
|
|
3575
4317
|
|
|
3576
|
-
-
|
|
3577
|
-
- Requires
|
|
4318
|
+
- Server Components and nested layouts.
|
|
4319
|
+
- Requires understanding server and client boundaries.
|
|
3578
4320
|
`
|
|
3579
4321
|
),
|
|
3580
|
-
|
|
3581
|
-
"
|
|
3582
|
-
"Use
|
|
3583
|
-
`# Proposed ADR: Use
|
|
4322
|
+
proposedAdr3(
|
|
4323
|
+
"data-layer",
|
|
4324
|
+
"Use a typed data layer with PostgreSQL",
|
|
4325
|
+
`# Proposed ADR: Use a typed data layer with PostgreSQL
|
|
3584
4326
|
|
|
3585
4327
|
## Status
|
|
3586
4328
|
|
|
@@ -3588,29 +4330,235 @@ Proposed
|
|
|
3588
4330
|
|
|
3589
4331
|
## Context
|
|
3590
4332
|
|
|
3591
|
-
The
|
|
4333
|
+
The app needs a database and a typed access layer.
|
|
3592
4334
|
|
|
3593
4335
|
## Decision
|
|
3594
4336
|
|
|
3595
|
-
Consider
|
|
4337
|
+
Consider Drizzle or Prisma with PostgreSQL, awaiting human acceptance.
|
|
3596
4338
|
|
|
3597
4339
|
## Alternatives Considered
|
|
3598
4340
|
|
|
3599
|
-
-
|
|
3600
|
-
-
|
|
4341
|
+
- A hosted backend or BaaS.
|
|
4342
|
+
- Raw SQL.
|
|
3601
4343
|
|
|
3602
4344
|
## Consequences
|
|
3603
4345
|
|
|
3604
|
-
-
|
|
3605
|
-
- Adds
|
|
4346
|
+
- Type-safe queries and migrations.
|
|
4347
|
+
- Adds an ORM and schema workflow.
|
|
3606
4348
|
`
|
|
3607
4349
|
),
|
|
3608
|
-
|
|
3609
|
-
"
|
|
3610
|
-
"Use
|
|
3611
|
-
`# Proposed ADR: Use
|
|
3612
|
-
|
|
3613
|
-
## Status
|
|
4350
|
+
proposedAdr3(
|
|
4351
|
+
"styling-tailwind",
|
|
4352
|
+
"Use Tailwind CSS",
|
|
4353
|
+
`# Proposed ADR: Use Tailwind CSS
|
|
4354
|
+
|
|
4355
|
+
## Status
|
|
4356
|
+
|
|
4357
|
+
Proposed
|
|
4358
|
+
|
|
4359
|
+
## Context
|
|
4360
|
+
|
|
4361
|
+
The app needs a styling approach.
|
|
4362
|
+
|
|
4363
|
+
## Decision
|
|
4364
|
+
|
|
4365
|
+
Consider Tailwind CSS for styling, awaiting human acceptance.
|
|
4366
|
+
|
|
4367
|
+
## Alternatives Considered
|
|
4368
|
+
|
|
4369
|
+
- CSS Modules.
|
|
4370
|
+
- A component library with its own styling.
|
|
4371
|
+
|
|
4372
|
+
## Consequences
|
|
4373
|
+
|
|
4374
|
+
- Fast, consistent utility-based styling.
|
|
4375
|
+
- Markup includes utility classes that teams must standardize.
|
|
4376
|
+
`
|
|
4377
|
+
),
|
|
4378
|
+
proposedAdr3(
|
|
4379
|
+
"testing",
|
|
4380
|
+
"Use Vitest and Playwright",
|
|
4381
|
+
`# Proposed ADR: Use Vitest and Playwright
|
|
4382
|
+
|
|
4383
|
+
## Status
|
|
4384
|
+
|
|
4385
|
+
Proposed
|
|
4386
|
+
|
|
4387
|
+
## Context
|
|
4388
|
+
|
|
4389
|
+
The app needs unit, component, and end-to-end testing.
|
|
4390
|
+
|
|
4391
|
+
## Decision
|
|
4392
|
+
|
|
4393
|
+
Consider Vitest with Testing Library and Playwright, awaiting human acceptance.
|
|
4394
|
+
|
|
4395
|
+
## Alternatives Considered
|
|
4396
|
+
|
|
4397
|
+
- Jest.
|
|
4398
|
+
- Cypress for end-to-end tests.
|
|
4399
|
+
|
|
4400
|
+
## Consequences
|
|
4401
|
+
|
|
4402
|
+
- Fast unit and component tests plus reliable end-to-end coverage.
|
|
4403
|
+
- Teams maintain two test toolchains.
|
|
4404
|
+
`
|
|
4405
|
+
)
|
|
4406
|
+
]
|
|
4407
|
+
};
|
|
4408
|
+
|
|
4409
|
+
// src/presets/python-fastapi/preset.ts
|
|
4410
|
+
var guidance4 = `# Python FastAPI Preset Guidance
|
|
4411
|
+
|
|
4412
|
+
This guidance is proposed, not accepted. Convert any choice you adopt into an accepted ADR in
|
|
4413
|
+
repository memory. Until then, treat everything here as a recommendation awaiting human review.
|
|
4414
|
+
|
|
4415
|
+
## Decision forks this stack forces
|
|
4416
|
+
|
|
4417
|
+
- Web framework: FastAPI vs Flask vs Django REST.
|
|
4418
|
+
- Database and access: PostgreSQL with SQLAlchemy and Alembic vs an async ORM vs raw SQL.
|
|
4419
|
+
- Validation and settings: Pydantic v2 models and settings.
|
|
4420
|
+
- Testing: pytest with httpx vs unittest.
|
|
4421
|
+
- Background work and caching: Redis, task queues, and async workers.
|
|
4422
|
+
|
|
4423
|
+
## Recommended structure (proposed)
|
|
4424
|
+
|
|
4425
|
+
- A layered layout: \`api/\` routers, \`services/\` logic, \`repositories/\` data access, \`models/\` schemas.
|
|
4426
|
+
- Dependency injection through FastAPI dependencies.
|
|
4427
|
+
- Configuration via Pydantic settings loaded from environment variables.
|
|
4428
|
+
|
|
4429
|
+
## Testing (proposed)
|
|
4430
|
+
|
|
4431
|
+
- pytest with the FastAPI test client or httpx \`AsyncClient\`.
|
|
4432
|
+
- A disposable test database and transactional fixtures.
|
|
4433
|
+
- Contract tests for request and response schemas.
|
|
4434
|
+
|
|
4435
|
+
## Security considerations (proposed)
|
|
4436
|
+
|
|
4437
|
+
- Load secrets from environment or a secret manager, never from source.
|
|
4438
|
+
- Validate and constrain all input with Pydantic models.
|
|
4439
|
+
- Scope authentication and authorization at the dependency layer.
|
|
4440
|
+
`;
|
|
4441
|
+
function proposedAdr4(topic, title, body) {
|
|
4442
|
+
return {
|
|
4443
|
+
id: `python-fastapi-${topic}`,
|
|
4444
|
+
title,
|
|
4445
|
+
status: "proposed",
|
|
4446
|
+
destination: `docs/adrs/proposed/ADR-PROPOSED-python-fastapi-${topic}.md`,
|
|
4447
|
+
body
|
|
4448
|
+
};
|
|
4449
|
+
}
|
|
4450
|
+
var pythonFastapiPreset = {
|
|
4451
|
+
id: "python-fastapi",
|
|
4452
|
+
name: "Python FastAPI",
|
|
4453
|
+
description: "Opinionated Python FastAPI opinion pack with proposed decisions only.",
|
|
4454
|
+
templates: [
|
|
4455
|
+
{
|
|
4456
|
+
destination: "docs/ai/presets/python-fastapi-guidance.md",
|
|
4457
|
+
description: "Python FastAPI guidance that remains proposed until accepted.",
|
|
4458
|
+
content: guidance4
|
|
4459
|
+
}
|
|
4460
|
+
],
|
|
4461
|
+
guidance: [
|
|
4462
|
+
{
|
|
4463
|
+
title: "Keep framework and data choices proposed",
|
|
4464
|
+
body: "FastAPI, the database and ORM, validation, and testing choices must remain proposed until accepted in repository memory."
|
|
4465
|
+
},
|
|
4466
|
+
{
|
|
4467
|
+
title: "Validate all input",
|
|
4468
|
+
body: "Use Pydantic models at the boundary, but record the validation approach as a proposed decision before treating it as accepted."
|
|
4469
|
+
}
|
|
4470
|
+
],
|
|
4471
|
+
proposedDecisions: [
|
|
4472
|
+
proposedAdr4(
|
|
4473
|
+
"framework",
|
|
4474
|
+
"Use FastAPI",
|
|
4475
|
+
`# Proposed ADR: Use FastAPI
|
|
4476
|
+
|
|
4477
|
+
## Status
|
|
4478
|
+
|
|
4479
|
+
Proposed
|
|
4480
|
+
|
|
4481
|
+
## Context
|
|
4482
|
+
|
|
4483
|
+
The service needs a Python web framework for an async API.
|
|
4484
|
+
|
|
4485
|
+
## Decision
|
|
4486
|
+
|
|
4487
|
+
Consider FastAPI as the web framework, awaiting human acceptance.
|
|
4488
|
+
|
|
4489
|
+
## Alternatives Considered
|
|
4490
|
+
|
|
4491
|
+
- Flask.
|
|
4492
|
+
- Django REST Framework.
|
|
4493
|
+
|
|
4494
|
+
## Consequences
|
|
4495
|
+
|
|
4496
|
+
- Async support and automatic OpenAPI docs.
|
|
4497
|
+
- Requires comfort with type hints and dependency injection.
|
|
4498
|
+
`
|
|
4499
|
+
),
|
|
4500
|
+
proposedAdr4(
|
|
4501
|
+
"database-postgres",
|
|
4502
|
+
"Use PostgreSQL with SQLAlchemy and Alembic",
|
|
4503
|
+
`# Proposed ADR: Use PostgreSQL with SQLAlchemy
|
|
4504
|
+
|
|
4505
|
+
## Status
|
|
4506
|
+
|
|
4507
|
+
Proposed
|
|
4508
|
+
|
|
4509
|
+
## Context
|
|
4510
|
+
|
|
4511
|
+
The service needs a relational database and a migration strategy.
|
|
4512
|
+
|
|
4513
|
+
## Decision
|
|
4514
|
+
|
|
4515
|
+
Consider PostgreSQL with SQLAlchemy and Alembic migrations, awaiting human acceptance.
|
|
4516
|
+
|
|
4517
|
+
## Alternatives Considered
|
|
4518
|
+
|
|
4519
|
+
- An async ORM such as Tortoise or SQLModel only.
|
|
4520
|
+
- Raw SQL with a lightweight driver.
|
|
4521
|
+
|
|
4522
|
+
## Consequences
|
|
4523
|
+
|
|
4524
|
+
- Mature tooling and explicit migrations.
|
|
4525
|
+
- Requires session and connection management discipline.
|
|
4526
|
+
`
|
|
4527
|
+
),
|
|
4528
|
+
proposedAdr4(
|
|
4529
|
+
"validation-pydantic",
|
|
4530
|
+
"Use Pydantic for validation and settings",
|
|
4531
|
+
`# Proposed ADR: Use Pydantic
|
|
4532
|
+
|
|
4533
|
+
## Status
|
|
4534
|
+
|
|
4535
|
+
Proposed
|
|
4536
|
+
|
|
4537
|
+
## Context
|
|
4538
|
+
|
|
4539
|
+
The service needs request validation and typed configuration.
|
|
4540
|
+
|
|
4541
|
+
## Decision
|
|
4542
|
+
|
|
4543
|
+
Consider Pydantic v2 models for validation and settings, awaiting human acceptance.
|
|
4544
|
+
|
|
4545
|
+
## Alternatives Considered
|
|
4546
|
+
|
|
4547
|
+
- Marshmallow.
|
|
4548
|
+
- Hand-written validation.
|
|
4549
|
+
|
|
4550
|
+
## Consequences
|
|
4551
|
+
|
|
4552
|
+
- Strong typing at the boundary and clear settings.
|
|
4553
|
+
- Adds Pydantic to the dependency surface.
|
|
4554
|
+
`
|
|
4555
|
+
),
|
|
4556
|
+
proposedAdr4(
|
|
4557
|
+
"testing-pytest",
|
|
4558
|
+
"Use pytest for testing",
|
|
4559
|
+
`# Proposed ADR: Use pytest
|
|
4560
|
+
|
|
4561
|
+
## Status
|
|
3614
4562
|
|
|
3615
4563
|
Proposed
|
|
3616
4564
|
|
|
@@ -3743,8 +4691,8 @@ function parsePreset(value) {
|
|
|
3743
4691
|
if (!result.success) {
|
|
3744
4692
|
throw new PresetValidationError(
|
|
3745
4693
|
result.error.issues.map((issue) => {
|
|
3746
|
-
const
|
|
3747
|
-
return `${
|
|
4694
|
+
const path17 = issue.path.length > 0 ? `${issue.path.join(".")}: ` : "";
|
|
4695
|
+
return `${path17}${issue.message}`;
|
|
3748
4696
|
})
|
|
3749
4697
|
);
|
|
3750
4698
|
}
|
|
@@ -3770,6 +4718,9 @@ var builtInPresets = validatePresetRegistry([
|
|
|
3770
4718
|
genericPreset,
|
|
3771
4719
|
iosSwiftPreset,
|
|
3772
4720
|
kotlinAndroidPreset,
|
|
4721
|
+
laravelApiPreset,
|
|
4722
|
+
laravelReactPreset,
|
|
4723
|
+
laravelVuePreset,
|
|
3773
4724
|
nextjsPreset,
|
|
3774
4725
|
pythonFastapiPreset
|
|
3775
4726
|
]);
|
|
@@ -3780,302 +4731,52 @@ function getPreset(id) {
|
|
|
3780
4731
|
return builtInPresets.find((preset) => preset.id === id);
|
|
3781
4732
|
}
|
|
3782
4733
|
|
|
3783
|
-
// src/
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
}
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
"Recall OS init write plan contains errors.",
|
|
3819
|
-
plan.entries.filter((entry) => entry.action === "error").map((entry) => `${entry.path}: ${entry.reason}`)
|
|
3820
|
-
);
|
|
3821
|
-
}
|
|
3822
|
-
const writeResult = await executeWritePlan(plan, { dryRun: options.dryRun });
|
|
3823
|
-
return {
|
|
3824
|
-
preset: preset?.id ?? null,
|
|
3825
|
-
dryRun: options.dryRun ?? false,
|
|
3826
|
-
plan,
|
|
3827
|
-
writeResult
|
|
3828
|
-
};
|
|
3829
|
-
}
|
|
3830
|
-
function formatInitResult(result) {
|
|
3831
|
-
const lines = [
|
|
3832
|
-
result.dryRun ? "Recall OS init dry run complete." : "Recall OS init complete.",
|
|
3833
|
-
`Preset: ${result.preset ?? "none"}`
|
|
3834
|
-
];
|
|
3835
|
-
appendWriteSummary(lines, {
|
|
3836
|
-
dryRun: result.dryRun,
|
|
3837
|
-
writeResult: result.writeResult
|
|
3838
|
-
});
|
|
3839
|
-
const hookWritten = result.writeResult.created.includes(PRE_COMMIT_HOOK_PATH) || result.writeResult.overwritten.includes(PRE_COMMIT_HOOK_PATH);
|
|
3840
|
-
if (hookWritten) {
|
|
3841
|
-
lines.push("");
|
|
3842
|
-
lines.push(
|
|
3843
|
-
result.dryRun ? "Pre-commit hook will be written to .recall/hooks/pre-commit." : "Pre-commit hook written to .recall/hooks/pre-commit."
|
|
3844
|
-
);
|
|
3845
|
-
lines.push(`Enable it once per clone: ${HOOKS_PATH_ACTIVATION_COMMAND}`);
|
|
3846
|
-
}
|
|
3847
|
-
if (!result.dryRun) {
|
|
3848
|
-
appendNextSteps(lines, [
|
|
3849
|
-
"Read CLAUDE.md and AGENTS.md, then the docs/ memory they point to.",
|
|
3850
|
-
"Plan your first feature: `recall feature create <name>`.",
|
|
3851
|
-
"Record a decision: `recall adr create <title>`.",
|
|
3852
|
-
"Check repository memory health anytime: `recall doctor`."
|
|
3853
|
-
]);
|
|
3854
|
-
}
|
|
3855
|
-
return `${lines.join("\n")}
|
|
3856
|
-
`;
|
|
3857
|
-
}
|
|
3858
|
-
function resolvePreset(presetId) {
|
|
3859
|
-
if (presetId === void 0) {
|
|
3860
|
-
return null;
|
|
3861
|
-
}
|
|
3862
|
-
const preset = getPreset(presetId);
|
|
3863
|
-
if (preset === void 0) {
|
|
3864
|
-
throw new InitError("UNKNOWN_PRESET", `Unknown preset "${presetId}".`);
|
|
3865
|
-
}
|
|
3866
|
-
return preset;
|
|
3867
|
-
}
|
|
3868
|
-
function createInitWriteFiles(rootDir, config, preset) {
|
|
3869
|
-
return [
|
|
3870
|
-
{
|
|
3871
|
-
path: CONFIG_PATH,
|
|
3872
|
-
content: `${JSON.stringify(config, null, 2)}
|
|
3873
|
-
`
|
|
3874
|
-
},
|
|
3875
|
-
...generateInitFiles({ rootDir, preset }),
|
|
3876
|
-
{
|
|
3877
|
-
path: PRE_COMMIT_HOOK_PATH,
|
|
3878
|
-
content: renderPreCommitHook(config.preCommitGates),
|
|
3879
|
-
executable: true
|
|
3880
|
-
}
|
|
3881
|
-
];
|
|
3882
|
-
}
|
|
3883
|
-
|
|
3884
|
-
// src/core/mcp/known-servers.ts
|
|
3885
|
-
var KNOWN_SERVERS = {
|
|
3886
|
-
figma: {
|
|
3887
|
-
title: "Figma",
|
|
3888
|
-
purpose: "Design variables, components, and layout metadata for building consistent UI.",
|
|
3889
|
-
dataAccessed: [
|
|
3890
|
-
"Design tokens and variables.",
|
|
3891
|
-
"Component and layout metadata.",
|
|
3892
|
-
"Frames and styles."
|
|
3893
|
-
]
|
|
3894
|
-
},
|
|
3895
|
-
linear: {
|
|
3896
|
-
title: "Linear",
|
|
3897
|
-
purpose: "Tickets, project status, and acceptance criteria.",
|
|
3898
|
-
dataAccessed: [
|
|
3899
|
-
"Issues and tickets.",
|
|
3900
|
-
"Project and cycle status.",
|
|
3901
|
-
"Acceptance criteria in issues."
|
|
3902
|
-
]
|
|
3903
|
-
},
|
|
3904
|
-
jira: {
|
|
3905
|
-
title: "Jira",
|
|
3906
|
-
purpose: "Tickets, sprints, and acceptance criteria for knocking out tasks.",
|
|
3907
|
-
dataAccessed: [
|
|
3908
|
-
"Issues and tickets.",
|
|
3909
|
-
"Sprint and board status.",
|
|
3910
|
-
"Acceptance criteria in issues."
|
|
3911
|
-
]
|
|
3912
|
-
},
|
|
3913
|
-
github: {
|
|
3914
|
-
title: "GitHub",
|
|
3915
|
-
purpose: "Pull requests, issues, and review comments.",
|
|
3916
|
-
dataAccessed: ["Pull requests and diffs.", "Issues.", "Review comments."]
|
|
3917
|
-
},
|
|
3918
|
-
sentry: {
|
|
3919
|
-
title: "Sentry",
|
|
3920
|
-
purpose: "Crash reports and production errors.",
|
|
3921
|
-
dataAccessed: ["Error events and stack traces.", "Release health.", "Issue frequency."]
|
|
3922
|
-
},
|
|
3923
|
-
notion: {
|
|
3924
|
-
title: "Notion",
|
|
3925
|
-
purpose: "Product background and documentation.",
|
|
3926
|
-
dataAccessed: ["Product docs and pages.", "Project background.", "Specifications."]
|
|
3927
|
-
}
|
|
3928
|
-
};
|
|
3929
|
-
function getKnownServer(id) {
|
|
3930
|
-
return KNOWN_SERVERS[id];
|
|
3931
|
-
}
|
|
3932
|
-
|
|
3933
|
-
// src/core/mcp/generate-mcp.ts
|
|
3934
|
-
function mcpDocPath(server) {
|
|
3935
|
-
return `docs/ai/mcp/${server}.md`;
|
|
3936
|
-
}
|
|
3937
|
-
function generateMcpFiles(options) {
|
|
3938
|
-
const known = getKnownServer(options.server);
|
|
3939
|
-
const title = known?.title ?? titleize(options.server);
|
|
3940
|
-
const purpose = known?.purpose ?? "Describe why this MCP server is used.";
|
|
3941
|
-
const dataAccessed = known?.dataAccessed ?? ["Describe the data this MCP server exposes."];
|
|
3942
|
-
return [
|
|
3943
|
-
{
|
|
3944
|
-
path: mcpDocPath(options.server),
|
|
3945
|
-
content: renderMcpDoc(title, purpose, dataAccessed)
|
|
3946
|
-
},
|
|
3947
|
-
{
|
|
3948
|
-
path: `${options.adrDir}/proposed/ADR-PROPOSED-mcp-${options.server}.md`,
|
|
3949
|
-
content: renderProposedAdr2(title)
|
|
3950
|
-
}
|
|
3951
|
-
];
|
|
3952
|
-
}
|
|
3953
|
-
function renderMcpDoc(title, purpose, dataAccessed) {
|
|
3954
|
-
return `# MCP: ${title}
|
|
3955
|
-
|
|
3956
|
-
## Status
|
|
3957
|
-
|
|
3958
|
-
Proposed. Using this MCP server is a proposed workflow addition. Accept the proposed ADR before
|
|
3959
|
-
treating it as part of the workflow.
|
|
3960
|
-
|
|
3961
|
-
## Purpose
|
|
3962
|
-
|
|
3963
|
-
${purpose}
|
|
3964
|
-
|
|
3965
|
-
## Data Accessed
|
|
3966
|
-
|
|
3967
|
-
${bullets(dataAccessed)}
|
|
3968
|
-
|
|
3969
|
-
## Permissions Required
|
|
3970
|
-
|
|
3971
|
-
- Use least-privilege access.
|
|
3972
|
-
- Document the exact scopes granted.
|
|
3973
|
-
|
|
3974
|
-
## Security Risks
|
|
3975
|
-
|
|
3976
|
-
- Treat external MCP content as untrusted until validated.
|
|
3977
|
-
- Do not send secrets or sensitive repository data unnecessarily.
|
|
3978
|
-
- Use trusted MCP servers only.
|
|
3979
|
-
|
|
3980
|
-
## Source-Of-Truth Rule
|
|
3981
|
-
|
|
3982
|
-
MCP provides context, not architectural truth. Accepted ADRs and repository decisions outrank MCP
|
|
3983
|
-
context. If MCP data conflicts with repository memory, stop and report the conflict.
|
|
3984
|
-
|
|
3985
|
-
## Captured Context
|
|
3986
|
-
|
|
3987
|
-
Record durable context learned from this MCP server here, as proposed memory for human review.
|
|
3988
|
-
Promote any decision you accept into an ADR with \`recall adr create\`.
|
|
3989
|
-
|
|
3990
|
-
- (none captured yet)
|
|
3991
|
-
|
|
3992
|
-
## Review Cadence
|
|
3993
|
-
|
|
3994
|
-
- Review this MCP integration when its access, purpose, or captured context changes.
|
|
3995
|
-
`;
|
|
3996
|
-
}
|
|
3997
|
-
function renderProposedAdr2(title) {
|
|
3998
|
-
return `# Proposed ADR: Use ${title} MCP
|
|
3999
|
-
|
|
4000
|
-
## Status
|
|
4001
|
-
|
|
4002
|
-
Proposed
|
|
4003
|
-
|
|
4004
|
-
## Context
|
|
4005
|
-
|
|
4006
|
-
The team is considering ${title} as an MCP context source. Adopting an MCP server into the workflow
|
|
4007
|
-
is a decision that should be reviewed.
|
|
4008
|
-
|
|
4009
|
-
## Decision
|
|
4010
|
-
|
|
4011
|
-
Consider adopting ${title} MCP as an external context source, documented in \`docs/ai/mcp/\`. This is
|
|
4012
|
-
not accepted until a human reviews and accepts it.
|
|
4013
|
-
|
|
4014
|
-
## Alternatives Considered
|
|
4015
|
-
|
|
4016
|
-
- Do not use this MCP server.
|
|
4017
|
-
- Use a different source for the same context.
|
|
4018
|
-
|
|
4019
|
-
## Consequences
|
|
4020
|
-
|
|
4021
|
-
- The team gains durable, reviewable context from ${title}.
|
|
4022
|
-
- MCP context never overrides accepted repository memory.
|
|
4023
|
-
- Captured context remains proposed until promoted to an ADR.
|
|
4024
|
-
`;
|
|
4025
|
-
}
|
|
4026
|
-
function bullets(values) {
|
|
4027
|
-
return values.map((value) => `- ${value}`).join("\n");
|
|
4028
|
-
}
|
|
4029
|
-
function titleize(value) {
|
|
4030
|
-
return value.split("-").filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
4031
|
-
}
|
|
4032
|
-
|
|
4033
|
-
// src/core/skills/render-skill.ts
|
|
4034
|
-
function renderSkill(skill) {
|
|
4035
|
-
const lines = [
|
|
4036
|
-
"---",
|
|
4037
|
-
`name: ${skill.name}`,
|
|
4038
|
-
// JSON-stringify yields a valid double-quoted YAML scalar, so descriptions with any punctuation
|
|
4039
|
-
// stay valid Agent Skills frontmatter.
|
|
4040
|
-
`description: ${JSON.stringify(skill.description)}`,
|
|
4041
|
-
"---",
|
|
4042
|
-
"",
|
|
4043
|
-
`# Skill: ${skill.title}`,
|
|
4044
|
-
"",
|
|
4045
|
-
"## Purpose",
|
|
4046
|
-
"",
|
|
4047
|
-
...paragraphs(skill.purpose),
|
|
4048
|
-
"",
|
|
4049
|
-
"## Inputs",
|
|
4050
|
-
"",
|
|
4051
|
-
...bullets2(skill.inputs),
|
|
4052
|
-
"",
|
|
4053
|
-
"## Required Reading",
|
|
4054
|
-
"",
|
|
4055
|
-
...bullets2(skill.requiredReading),
|
|
4056
|
-
"",
|
|
4057
|
-
"## Output Files",
|
|
4058
|
-
"",
|
|
4059
|
-
...bullets2(skill.outputFiles),
|
|
4060
|
-
"",
|
|
4061
|
-
"## Process",
|
|
4062
|
-
"",
|
|
4063
|
-
...numbered(skill.process),
|
|
4064
|
-
""
|
|
4065
|
-
];
|
|
4066
|
-
for (const section of skill.extraSections ?? []) {
|
|
4067
|
-
lines.push(`## ${section.heading}`, "", ...bullets2(section.bullets), "");
|
|
4734
|
+
// src/core/skills/render-skill.ts
|
|
4735
|
+
function renderSkill(skill) {
|
|
4736
|
+
const lines = [
|
|
4737
|
+
"---",
|
|
4738
|
+
`name: ${skill.name}`,
|
|
4739
|
+
// JSON-stringify yields a valid double-quoted YAML scalar, so descriptions with any punctuation
|
|
4740
|
+
// stay valid Agent Skills frontmatter.
|
|
4741
|
+
`description: ${JSON.stringify(skill.description)}`,
|
|
4742
|
+
"---",
|
|
4743
|
+
"",
|
|
4744
|
+
`# Skill: ${skill.title}`,
|
|
4745
|
+
"",
|
|
4746
|
+
"## Purpose",
|
|
4747
|
+
"",
|
|
4748
|
+
...paragraphs(skill.purpose),
|
|
4749
|
+
"",
|
|
4750
|
+
"## Inputs",
|
|
4751
|
+
"",
|
|
4752
|
+
...bullets(skill.inputs),
|
|
4753
|
+
"",
|
|
4754
|
+
"## Required Reading",
|
|
4755
|
+
"",
|
|
4756
|
+
...bullets(skill.requiredReading),
|
|
4757
|
+
"",
|
|
4758
|
+
"## Output Files",
|
|
4759
|
+
"",
|
|
4760
|
+
...bullets(skill.outputFiles),
|
|
4761
|
+
"",
|
|
4762
|
+
"## Process",
|
|
4763
|
+
"",
|
|
4764
|
+
...numbered(skill.process),
|
|
4765
|
+
""
|
|
4766
|
+
];
|
|
4767
|
+
for (const section of skill.extraSections ?? []) {
|
|
4768
|
+
lines.push(`## ${section.heading}`, "", ...bullets(section.bullets), "");
|
|
4068
4769
|
}
|
|
4069
4770
|
lines.push(
|
|
4070
4771
|
"## Stop Conditions",
|
|
4071
4772
|
"",
|
|
4072
4773
|
"Stop and request human decision if:",
|
|
4073
4774
|
"",
|
|
4074
|
-
...
|
|
4775
|
+
...bullets(skill.stopConditions),
|
|
4075
4776
|
"",
|
|
4076
4777
|
"## Quality Bar",
|
|
4077
4778
|
"",
|
|
4078
|
-
...
|
|
4779
|
+
...bullets(skill.qualityBar)
|
|
4079
4780
|
);
|
|
4080
4781
|
return `${lines.join("\n")}
|
|
4081
4782
|
`;
|
|
@@ -4090,7 +4791,7 @@ function paragraphs(values) {
|
|
|
4090
4791
|
});
|
|
4091
4792
|
return out;
|
|
4092
4793
|
}
|
|
4093
|
-
function
|
|
4794
|
+
function bullets(values) {
|
|
4094
4795
|
return values.map((value) => `- ${value}`);
|
|
4095
4796
|
}
|
|
4096
4797
|
function numbered(values) {
|
|
@@ -4535,134 +5236,432 @@ var SKILL_CATALOG = [
|
|
|
4535
5236
|
"Future agents can tell what the module owns and what it must not own."
|
|
4536
5237
|
]
|
|
4537
5238
|
},
|
|
4538
|
-
{
|
|
4539
|
-
name: "completion-report",
|
|
4540
|
-
title: "Completion Report",
|
|
4541
|
-
description: "Write a completion report with files changed, tests run, results, skipped checks, docs updated, remaining risks, and release readiness notes. Use when recording evidence that a task or feature is complete and ready for review.",
|
|
4542
|
-
purpose: ["Record evidence that a task is complete and safe to review."],
|
|
4543
|
-
inputs: [
|
|
4544
|
-
"Task or feature summary.",
|
|
4545
|
-
"Files changed.",
|
|
4546
|
-
"Commands run.",
|
|
4547
|
-
"Test results.",
|
|
4548
|
-
"Docs updated.",
|
|
4549
|
-
"Known risks."
|
|
4550
|
-
],
|
|
4551
|
-
requiredReading: [
|
|
4552
|
-
"`docs/50-quality/QUALITY_GATES.md`",
|
|
4553
|
-
"`docs/60-engineering/ENGINEERING_STANDARDS.md`",
|
|
4554
|
-
"Relevant feature `TASKS.md`",
|
|
4555
|
-
"Relevant feature `TEST_PLAN.md`",
|
|
4556
|
-
"Relevant feature `REVIEW.md`"
|
|
4557
|
-
],
|
|
4558
|
-
outputFiles: [
|
|
4559
|
-
"Relevant feature `COMPLETION_REPORT.md`",
|
|
4560
|
-
"Task or feature docs that need final status updates."
|
|
4561
|
-
],
|
|
4562
|
-
process: [
|
|
4563
|
-
"Summarize the completed scope.",
|
|
4564
|
-
"List files changed by category.",
|
|
4565
|
-
"List commands run and results.",
|
|
4566
|
-
"List skipped checks and why.",
|
|
4567
|
-
"List docs updated.",
|
|
4568
|
-
"State whether engineering standards were followed.",
|
|
4569
|
-
"List remaining risks and follow-up work.",
|
|
4570
|
-
"State whether the task meets the definition of done."
|
|
4571
|
-
],
|
|
4572
|
-
stopConditions: [
|
|
4573
|
-
"Test results are missing for risky changes.",
|
|
4574
|
-
"Completion claims conflict with evidence.",
|
|
4575
|
-
"Required docs were not updated.",
|
|
4576
|
-
"Engineering standards were violated.",
|
|
4577
|
-
"Remaining risks are release blockers."
|
|
4578
|
-
],
|
|
4579
|
-
qualityBar: [
|
|
4580
|
-
"The report is evidence-based.",
|
|
4581
|
-
"It does not hide skipped checks.",
|
|
4582
|
-
"It separates completed work from remaining risk.",
|
|
4583
|
-
"A reviewer can decide what to do next from the report alone."
|
|
5239
|
+
{
|
|
5240
|
+
name: "completion-report",
|
|
5241
|
+
title: "Completion Report",
|
|
5242
|
+
description: "Write a completion report with files changed, tests run, results, skipped checks, docs updated, remaining risks, and release readiness notes. Use when recording evidence that a task or feature is complete and ready for review.",
|
|
5243
|
+
purpose: ["Record evidence that a task is complete and safe to review."],
|
|
5244
|
+
inputs: [
|
|
5245
|
+
"Task or feature summary.",
|
|
5246
|
+
"Files changed.",
|
|
5247
|
+
"Commands run.",
|
|
5248
|
+
"Test results.",
|
|
5249
|
+
"Docs updated.",
|
|
5250
|
+
"Known risks."
|
|
5251
|
+
],
|
|
5252
|
+
requiredReading: [
|
|
5253
|
+
"`docs/50-quality/QUALITY_GATES.md`",
|
|
5254
|
+
"`docs/60-engineering/ENGINEERING_STANDARDS.md`",
|
|
5255
|
+
"Relevant feature `TASKS.md`",
|
|
5256
|
+
"Relevant feature `TEST_PLAN.md`",
|
|
5257
|
+
"Relevant feature `REVIEW.md`"
|
|
5258
|
+
],
|
|
5259
|
+
outputFiles: [
|
|
5260
|
+
"Relevant feature `COMPLETION_REPORT.md`",
|
|
5261
|
+
"Task or feature docs that need final status updates."
|
|
5262
|
+
],
|
|
5263
|
+
process: [
|
|
5264
|
+
"Summarize the completed scope.",
|
|
5265
|
+
"List files changed by category.",
|
|
5266
|
+
"List commands run and results.",
|
|
5267
|
+
"List skipped checks and why.",
|
|
5268
|
+
"List docs updated.",
|
|
5269
|
+
"State whether engineering standards were followed.",
|
|
5270
|
+
"List remaining risks and follow-up work.",
|
|
5271
|
+
"State whether the task meets the definition of done."
|
|
5272
|
+
],
|
|
5273
|
+
stopConditions: [
|
|
5274
|
+
"Test results are missing for risky changes.",
|
|
5275
|
+
"Completion claims conflict with evidence.",
|
|
5276
|
+
"Required docs were not updated.",
|
|
5277
|
+
"Engineering standards were violated.",
|
|
5278
|
+
"Remaining risks are release blockers."
|
|
5279
|
+
],
|
|
5280
|
+
qualityBar: [
|
|
5281
|
+
"The report is evidence-based.",
|
|
5282
|
+
"It does not hide skipped checks.",
|
|
5283
|
+
"It separates completed work from remaining risk.",
|
|
5284
|
+
"A reviewer can decide what to do next from the report alone."
|
|
5285
|
+
]
|
|
5286
|
+
},
|
|
5287
|
+
{
|
|
5288
|
+
name: "capture-mcp-context",
|
|
5289
|
+
title: "Capture MCP Context",
|
|
5290
|
+
description: "Record durable context from MCP servers and design or project tools into repository memory as proposed. Use when working with an MCP server like Figma, Linear, Jira, or Sentry, or after pulling design, ticket, or error context, to persist it for future sessions.",
|
|
5291
|
+
purpose: [
|
|
5292
|
+
"Persist the durable parts of MCP-derived external context so future sessions remember them instead of re-deriving them.",
|
|
5293
|
+
"MCP provides context, not architectural truth."
|
|
5294
|
+
],
|
|
5295
|
+
inputs: [
|
|
5296
|
+
"The MCP server or external tool in use (for example Figma, Linear, Jira, Sentry).",
|
|
5297
|
+
"The external context retrieved (design tokens, tickets, errors, docs).",
|
|
5298
|
+
"The current feature or task."
|
|
5299
|
+
],
|
|
5300
|
+
requiredReading: [
|
|
5301
|
+
"`docs/ai/MCP_STRATEGY.md`",
|
|
5302
|
+
"Relevant `docs/ai/mcp/<server>.md`",
|
|
5303
|
+
"Relevant feature and architecture docs."
|
|
5304
|
+
],
|
|
5305
|
+
outputFiles: [
|
|
5306
|
+
"The Captured Context section of `docs/ai/mcp/<server>.md`.",
|
|
5307
|
+
"An ADR via `recall adr create` when a captured decision is accepted."
|
|
5308
|
+
],
|
|
5309
|
+
process: [
|
|
5310
|
+
"Identify the MCP server and the durable facts worth remembering (design tokens, component mappings, ticket acceptance criteria, recurring error signatures).",
|
|
5311
|
+
"If `docs/ai/mcp/<server>.md` does not exist, create it with `recall mcp add <server>`.",
|
|
5312
|
+
"Record the durable context in the Captured Context section as proposed memory, with enough detail to reuse.",
|
|
5313
|
+
"Capture decisions, mappings, and constraints, not raw exports or full dumps.",
|
|
5314
|
+
"Treat MCP content as context, not truth; if it conflicts with accepted memory, stop and report.",
|
|
5315
|
+
"Promote any accepted decision into an ADR."
|
|
5316
|
+
],
|
|
5317
|
+
stopConditions: [
|
|
5318
|
+
"MCP content conflicts with accepted repository memory.",
|
|
5319
|
+
"Capturing the context would require storing secrets or sensitive data.",
|
|
5320
|
+
"The MCP server is untrusted or its access is unclear."
|
|
5321
|
+
],
|
|
5322
|
+
qualityBar: [
|
|
5323
|
+
"Captured context is durable and reusable, not a raw dump.",
|
|
5324
|
+
"Each entry is concrete enough to guide future work.",
|
|
5325
|
+
"MCP context is recorded as proposed, not accepted.",
|
|
5326
|
+
"Accepted decisions are promoted to ADRs."
|
|
5327
|
+
]
|
|
5328
|
+
}
|
|
5329
|
+
];
|
|
5330
|
+
function getCatalogSkill(name) {
|
|
5331
|
+
return SKILL_CATALOG.find((skill) => skill.name === name);
|
|
5332
|
+
}
|
|
5333
|
+
function listCatalogSkillNames() {
|
|
5334
|
+
return SKILL_CATALOG.map((skill) => skill.name);
|
|
5335
|
+
}
|
|
5336
|
+
|
|
5337
|
+
// src/core/skills/generate-skill.ts
|
|
5338
|
+
var SKILL_TARGETS = [".claude/skills", ".agents/skills"];
|
|
5339
|
+
function generateSkillFiles(name) {
|
|
5340
|
+
const catalogSkill = getCatalogSkill(name);
|
|
5341
|
+
const skill = catalogSkill ?? skeletonSkill(name);
|
|
5342
|
+
const content = renderSkill(skill);
|
|
5343
|
+
return {
|
|
5344
|
+
files: SKILL_TARGETS.map((target) => ({
|
|
5345
|
+
path: `${target}/${name}/SKILL.md`,
|
|
5346
|
+
content
|
|
5347
|
+
})),
|
|
5348
|
+
fromCatalog: catalogSkill !== void 0
|
|
5349
|
+
};
|
|
5350
|
+
}
|
|
5351
|
+
function skeletonSkill(name) {
|
|
5352
|
+
return {
|
|
5353
|
+
name,
|
|
5354
|
+
title: titleize(name),
|
|
5355
|
+
description: `Describe what the ${name} skill does and when to use it. Use when ... (replace this with concrete trigger keywords).`,
|
|
5356
|
+
purpose: ["Describe the single job this skill performs."],
|
|
5357
|
+
inputs: ["List the inputs this skill needs."],
|
|
5358
|
+
requiredReading: ["List the source-of-truth docs this skill must read."],
|
|
5359
|
+
outputFiles: ["List the files this skill produces or updates."],
|
|
5360
|
+
process: ["Describe the steps, one job, routing to source-of-truth docs."],
|
|
5361
|
+
stopConditions: [
|
|
5362
|
+
"A request conflicts with accepted repository memory or engineering standards.",
|
|
5363
|
+
"The work would add network, telemetry, MCP runtime, AI API, or other accepted non-goals."
|
|
5364
|
+
],
|
|
5365
|
+
qualityBar: ["State how to tell the skill did its job well."]
|
|
5366
|
+
};
|
|
5367
|
+
}
|
|
5368
|
+
function titleize(name) {
|
|
5369
|
+
return name.split("-").filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
5370
|
+
}
|
|
5371
|
+
|
|
5372
|
+
// src/commands/init.ts
|
|
5373
|
+
var InitError = class extends Error {
|
|
5374
|
+
code;
|
|
5375
|
+
details;
|
|
5376
|
+
constructor(code, message, details = []) {
|
|
5377
|
+
super(message);
|
|
5378
|
+
this.name = "InitError";
|
|
5379
|
+
this.code = code;
|
|
5380
|
+
this.details = details;
|
|
5381
|
+
}
|
|
5382
|
+
};
|
|
5383
|
+
async function initProject(options) {
|
|
5384
|
+
if (options.force === true && options.reinit !== true && existsSync6(path15.join(options.rootDir, CONFIG_PATH))) {
|
|
5385
|
+
throw new InitError(
|
|
5386
|
+
"EXISTING_INSTALLATION",
|
|
5387
|
+
"Refusing to re-initialize an existing Recall OS installation.",
|
|
5388
|
+
[
|
|
5389
|
+
"An existing .recall/config.json was found in this directory.",
|
|
5390
|
+
"Running init --force here would overwrite existing repository memory.",
|
|
5391
|
+
"Pass --reinit together with --force to overwrite an existing installation."
|
|
5392
|
+
]
|
|
5393
|
+
);
|
|
5394
|
+
}
|
|
5395
|
+
const preset = resolvePreset(options.preset);
|
|
5396
|
+
const detected = await inspectRepo(options.rootDir);
|
|
5397
|
+
const preCommitGates = await detectPreCommitGates(options.rootDir);
|
|
5398
|
+
const config = createDefaultConfig({ preset: preset?.id ?? null, preCommitGates });
|
|
5399
|
+
const files = createInitWriteFiles(options.rootDir, config, preset);
|
|
5400
|
+
const plan = createWritePlan({
|
|
5401
|
+
rootDir: options.rootDir,
|
|
5402
|
+
files,
|
|
5403
|
+
force: options.force
|
|
5404
|
+
});
|
|
5405
|
+
if (plan.hasErrors) {
|
|
5406
|
+
throw new InitError(
|
|
5407
|
+
"WRITE_PLAN_ERROR",
|
|
5408
|
+
"Recall OS init write plan contains errors.",
|
|
5409
|
+
plan.entries.filter((entry) => entry.action === "error").map((entry) => `${entry.path}: ${entry.reason}`)
|
|
5410
|
+
);
|
|
5411
|
+
}
|
|
5412
|
+
const writeResult = await executeWritePlan(plan, { dryRun: options.dryRun });
|
|
5413
|
+
return {
|
|
5414
|
+
preset: preset?.id ?? null,
|
|
5415
|
+
dryRun: options.dryRun ?? false,
|
|
5416
|
+
plan,
|
|
5417
|
+
writeResult,
|
|
5418
|
+
detected
|
|
5419
|
+
};
|
|
5420
|
+
}
|
|
5421
|
+
function formatInitResult(result) {
|
|
5422
|
+
const lines = [
|
|
5423
|
+
result.dryRun ? "Recall OS init dry run complete." : "Recall OS init complete.",
|
|
5424
|
+
`Preset: ${result.preset ?? "none"}`
|
|
5425
|
+
];
|
|
5426
|
+
if (!result.dryRun) {
|
|
5427
|
+
lines.push(
|
|
5428
|
+
`Generated repository memory, ${listCatalogSkillNames().length} agent skills, a pre-commit hook, a CI workflow, a Claude SessionStart hook, and a Cursor rule that load memory automatically.`
|
|
5429
|
+
);
|
|
5430
|
+
}
|
|
5431
|
+
appendWriteSummary(lines, {
|
|
5432
|
+
dryRun: result.dryRun,
|
|
5433
|
+
writeResult: result.writeResult
|
|
5434
|
+
});
|
|
5435
|
+
appendDetectedStack(lines, result.detected);
|
|
5436
|
+
const hookWritten = result.writeResult.created.includes(PRE_COMMIT_HOOK_PATH) || result.writeResult.overwritten.includes(PRE_COMMIT_HOOK_PATH);
|
|
5437
|
+
if (hookWritten) {
|
|
5438
|
+
lines.push("");
|
|
5439
|
+
lines.push(
|
|
5440
|
+
result.dryRun ? "Pre-commit hook will be written to .recall/hooks/pre-commit." : "Pre-commit hook written to .recall/hooks/pre-commit."
|
|
5441
|
+
);
|
|
5442
|
+
lines.push(`Enable it once per clone: ${HOOKS_PATH_ACTIVATION_COMMAND}`);
|
|
5443
|
+
}
|
|
5444
|
+
if (!result.dryRun) {
|
|
5445
|
+
appendNextSteps(lines, [
|
|
5446
|
+
"Read CLAUDE.md and AGENTS.md, then the docs/ memory they point to.",
|
|
5447
|
+
"AI agent skills are in .claude/skills/ and .agents/skills/ \u2014 restart your AI tool to load them.",
|
|
5448
|
+
"Memory loads automatically per tool: a Claude SessionStart hook (.claude/hooks/session-start.sh), a Cursor rule (.cursor/rules/recall-memory.mdc), and AGENTS.md for Codex.",
|
|
5449
|
+
"CI is wired in .github/workflows/recall.yml; the pre-commit hook is in .recall/hooks/.",
|
|
5450
|
+
"Plan your first feature: `recall feature create <name>`.",
|
|
5451
|
+
"Record a decision: `recall adr create <title>`, then accept it with `recall adr accept`.",
|
|
5452
|
+
"Check repository memory health anytime: `recall doctor`."
|
|
5453
|
+
]);
|
|
5454
|
+
}
|
|
5455
|
+
return `${lines.join("\n")}
|
|
5456
|
+
`;
|
|
5457
|
+
}
|
|
5458
|
+
function appendDetectedStack(lines, detected) {
|
|
5459
|
+
const hasSignal = detected.languages.length > 0 || detected.frameworks.length > 0 || detected.packageManager !== null || detected.testsEvidence !== null;
|
|
5460
|
+
if (!hasSignal) {
|
|
5461
|
+
return;
|
|
5462
|
+
}
|
|
5463
|
+
const stack = summarizeSignals(detected).filter(
|
|
5464
|
+
(line) => !line.startsWith("- README") && !line.startsWith("- Docs")
|
|
5465
|
+
);
|
|
5466
|
+
lines.push("");
|
|
5467
|
+
lines.push("Detected in this repository (proposed \u2014 review, nothing was accepted):");
|
|
5468
|
+
lines.push(...stack);
|
|
5469
|
+
lines.push(
|
|
5470
|
+
"If any signal is wrong, correct the source file noted. Run `recall adopt` to record this as proposed memory."
|
|
5471
|
+
);
|
|
5472
|
+
}
|
|
5473
|
+
function resolvePreset(presetId) {
|
|
5474
|
+
if (presetId === void 0) {
|
|
5475
|
+
return null;
|
|
5476
|
+
}
|
|
5477
|
+
const preset = getPreset(presetId);
|
|
5478
|
+
if (preset === void 0) {
|
|
5479
|
+
throw new InitError("UNKNOWN_PRESET", `Unknown preset "${presetId}".`);
|
|
5480
|
+
}
|
|
5481
|
+
return preset;
|
|
5482
|
+
}
|
|
5483
|
+
function createInitWriteFiles(rootDir, config, preset) {
|
|
5484
|
+
return [
|
|
5485
|
+
{
|
|
5486
|
+
path: CONFIG_PATH,
|
|
5487
|
+
content: `${JSON.stringify(config, null, 2)}
|
|
5488
|
+
`
|
|
5489
|
+
},
|
|
5490
|
+
...generateInitFiles({ rootDir, preset }),
|
|
5491
|
+
{
|
|
5492
|
+
path: PRE_COMMIT_HOOK_PATH,
|
|
5493
|
+
content: renderPreCommitHook(config.preCommitGates),
|
|
5494
|
+
executable: true
|
|
5495
|
+
},
|
|
5496
|
+
// A Claude Code SessionStart hook that injects a memory map every session, so a fresh agent
|
|
5497
|
+
// reliably loads durable memory, plus the settings that wire it (skipped if settings exist).
|
|
5498
|
+
{
|
|
5499
|
+
path: SESSION_START_HOOK_PATH,
|
|
5500
|
+
content: renderSessionStartHook(),
|
|
5501
|
+
executable: true
|
|
5502
|
+
},
|
|
5503
|
+
{
|
|
5504
|
+
path: CLAUDE_SETTINGS_PATH,
|
|
5505
|
+
content: renderClaudeSettings()
|
|
5506
|
+
},
|
|
5507
|
+
// Generate the agent skill set so a fresh repo has the workflows that guide AI agents,
|
|
5508
|
+
// not just the docs. Written to both the Claude and portable Agent Skills targets.
|
|
5509
|
+
...listCatalogSkillNames().flatMap((name) => generateSkillFiles(name).files)
|
|
5510
|
+
];
|
|
5511
|
+
}
|
|
5512
|
+
|
|
5513
|
+
// src/core/mcp/known-servers.ts
|
|
5514
|
+
var KNOWN_SERVERS = {
|
|
5515
|
+
figma: {
|
|
5516
|
+
title: "Figma",
|
|
5517
|
+
purpose: "Design variables, components, and layout metadata for building consistent UI.",
|
|
5518
|
+
dataAccessed: [
|
|
5519
|
+
"Design tokens and variables.",
|
|
5520
|
+
"Component and layout metadata.",
|
|
5521
|
+
"Frames and styles."
|
|
5522
|
+
]
|
|
5523
|
+
},
|
|
5524
|
+
linear: {
|
|
5525
|
+
title: "Linear",
|
|
5526
|
+
purpose: "Tickets, project status, and acceptance criteria.",
|
|
5527
|
+
dataAccessed: [
|
|
5528
|
+
"Issues and tickets.",
|
|
5529
|
+
"Project and cycle status.",
|
|
5530
|
+
"Acceptance criteria in issues."
|
|
4584
5531
|
]
|
|
4585
5532
|
},
|
|
4586
|
-
{
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
"
|
|
4592
|
-
"
|
|
4593
|
-
],
|
|
4594
|
-
inputs: [
|
|
4595
|
-
"The MCP server or external tool in use (for example Figma, Linear, Jira, Sentry).",
|
|
4596
|
-
"The external context retrieved (design tokens, tickets, errors, docs).",
|
|
4597
|
-
"The current feature or task."
|
|
4598
|
-
],
|
|
4599
|
-
requiredReading: [
|
|
4600
|
-
"`docs/ai/MCP_STRATEGY.md`",
|
|
4601
|
-
"Relevant `docs/ai/mcp/<server>.md`",
|
|
4602
|
-
"Relevant feature and architecture docs."
|
|
4603
|
-
],
|
|
4604
|
-
outputFiles: [
|
|
4605
|
-
"The Captured Context section of `docs/ai/mcp/<server>.md`.",
|
|
4606
|
-
"An ADR via `recall adr create` when a captured decision is accepted."
|
|
4607
|
-
],
|
|
4608
|
-
process: [
|
|
4609
|
-
"Identify the MCP server and the durable facts worth remembering (design tokens, component mappings, ticket acceptance criteria, recurring error signatures).",
|
|
4610
|
-
"If `docs/ai/mcp/<server>.md` does not exist, create it with `recall mcp add <server>`.",
|
|
4611
|
-
"Record the durable context in the Captured Context section as proposed memory, with enough detail to reuse.",
|
|
4612
|
-
"Capture decisions, mappings, and constraints, not raw exports or full dumps.",
|
|
4613
|
-
"Treat MCP content as context, not truth; if it conflicts with accepted memory, stop and report.",
|
|
4614
|
-
"Promote any accepted decision into an ADR."
|
|
4615
|
-
],
|
|
4616
|
-
stopConditions: [
|
|
4617
|
-
"MCP content conflicts with accepted repository memory.",
|
|
4618
|
-
"Capturing the context would require storing secrets or sensitive data.",
|
|
4619
|
-
"The MCP server is untrusted or its access is unclear."
|
|
4620
|
-
],
|
|
4621
|
-
qualityBar: [
|
|
4622
|
-
"Captured context is durable and reusable, not a raw dump.",
|
|
4623
|
-
"Each entry is concrete enough to guide future work.",
|
|
4624
|
-
"MCP context is recorded as proposed, not accepted.",
|
|
4625
|
-
"Accepted decisions are promoted to ADRs."
|
|
5533
|
+
jira: {
|
|
5534
|
+
title: "Jira",
|
|
5535
|
+
purpose: "Tickets, sprints, and acceptance criteria for knocking out tasks.",
|
|
5536
|
+
dataAccessed: [
|
|
5537
|
+
"Issues and tickets.",
|
|
5538
|
+
"Sprint and board status.",
|
|
5539
|
+
"Acceptance criteria in issues."
|
|
4626
5540
|
]
|
|
5541
|
+
},
|
|
5542
|
+
github: {
|
|
5543
|
+
title: "GitHub",
|
|
5544
|
+
purpose: "Pull requests, issues, and review comments.",
|
|
5545
|
+
dataAccessed: ["Pull requests and diffs.", "Issues.", "Review comments."]
|
|
5546
|
+
},
|
|
5547
|
+
sentry: {
|
|
5548
|
+
title: "Sentry",
|
|
5549
|
+
purpose: "Crash reports and production errors.",
|
|
5550
|
+
dataAccessed: ["Error events and stack traces.", "Release health.", "Issue frequency."]
|
|
5551
|
+
},
|
|
5552
|
+
notion: {
|
|
5553
|
+
title: "Notion",
|
|
5554
|
+
purpose: "Product background and documentation.",
|
|
5555
|
+
dataAccessed: ["Product docs and pages.", "Project background.", "Specifications."]
|
|
4627
5556
|
}
|
|
4628
|
-
|
|
4629
|
-
function
|
|
4630
|
-
return
|
|
5557
|
+
};
|
|
5558
|
+
function getKnownServer(id) {
|
|
5559
|
+
return KNOWN_SERVERS[id];
|
|
4631
5560
|
}
|
|
4632
5561
|
|
|
4633
|
-
// src/core/
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
const catalogSkill = getCatalogSkill(name);
|
|
4637
|
-
const skill = catalogSkill ?? skeletonSkill(name);
|
|
4638
|
-
const content = renderSkill(skill);
|
|
4639
|
-
return {
|
|
4640
|
-
files: SKILL_TARGETS.map((target) => ({
|
|
4641
|
-
path: `${target}/${name}/SKILL.md`,
|
|
4642
|
-
content
|
|
4643
|
-
})),
|
|
4644
|
-
fromCatalog: catalogSkill !== void 0
|
|
4645
|
-
};
|
|
5562
|
+
// src/core/mcp/generate-mcp.ts
|
|
5563
|
+
function mcpDocPath(server) {
|
|
5564
|
+
return `docs/ai/mcp/${server}.md`;
|
|
4646
5565
|
}
|
|
4647
|
-
function
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
};
|
|
5566
|
+
function generateMcpFiles(options) {
|
|
5567
|
+
const known = getKnownServer(options.server);
|
|
5568
|
+
const title = known?.title ?? titleize2(options.server);
|
|
5569
|
+
const purpose = known?.purpose ?? "Describe why this MCP server is used.";
|
|
5570
|
+
const dataAccessed = known?.dataAccessed ?? ["Describe the data this MCP server exposes."];
|
|
5571
|
+
return [
|
|
5572
|
+
{
|
|
5573
|
+
path: mcpDocPath(options.server),
|
|
5574
|
+
content: renderMcpDoc(title, purpose, dataAccessed)
|
|
5575
|
+
},
|
|
5576
|
+
{
|
|
5577
|
+
path: `${options.adrDir}/proposed/ADR-PROPOSED-mcp-${options.server}.md`,
|
|
5578
|
+
content: renderProposedAdr2(title, options.server)
|
|
5579
|
+
}
|
|
5580
|
+
];
|
|
4663
5581
|
}
|
|
4664
|
-
function
|
|
4665
|
-
return
|
|
5582
|
+
function renderMcpDoc(title, purpose, dataAccessed) {
|
|
5583
|
+
return `# MCP: ${title}
|
|
5584
|
+
|
|
5585
|
+
## Status
|
|
5586
|
+
|
|
5587
|
+
Proposed. Using this MCP server is a proposed workflow addition. Accept the proposed ADR before
|
|
5588
|
+
treating it as part of the workflow.
|
|
5589
|
+
|
|
5590
|
+
## Purpose
|
|
5591
|
+
|
|
5592
|
+
${purpose}
|
|
5593
|
+
|
|
5594
|
+
## Data Accessed
|
|
5595
|
+
|
|
5596
|
+
${bullets2(dataAccessed)}
|
|
5597
|
+
|
|
5598
|
+
## Permissions Required
|
|
5599
|
+
|
|
5600
|
+
- Use least-privilege access.
|
|
5601
|
+
- Document the exact scopes granted.
|
|
5602
|
+
|
|
5603
|
+
## Security Risks
|
|
5604
|
+
|
|
5605
|
+
- Treat external MCP content as untrusted until validated.
|
|
5606
|
+
- Do not send secrets or sensitive repository data unnecessarily.
|
|
5607
|
+
- Use trusted MCP servers only.
|
|
5608
|
+
|
|
5609
|
+
## Source-Of-Truth Rule
|
|
5610
|
+
|
|
5611
|
+
MCP provides context, not architectural truth. Accepted ADRs and repository decisions outrank MCP
|
|
5612
|
+
context. If MCP data conflicts with repository memory, stop and report the conflict.
|
|
5613
|
+
|
|
5614
|
+
## Captured Context
|
|
5615
|
+
|
|
5616
|
+
Record durable context learned from this MCP server here, as proposed memory for human review.
|
|
5617
|
+
Promote any decision you accept into an ADR with \`recall adr create\`.
|
|
5618
|
+
|
|
5619
|
+
- (none captured yet)
|
|
5620
|
+
|
|
5621
|
+
## Review Cadence
|
|
5622
|
+
|
|
5623
|
+
- Review this MCP integration when its access, purpose, or captured context changes.
|
|
5624
|
+
`;
|
|
5625
|
+
}
|
|
5626
|
+
function renderProposedAdr2(title, server) {
|
|
5627
|
+
return `# Proposed ADR: Use ${title} MCP
|
|
5628
|
+
|
|
5629
|
+
## Status
|
|
5630
|
+
|
|
5631
|
+
Proposed
|
|
5632
|
+
|
|
5633
|
+
## Context
|
|
5634
|
+
|
|
5635
|
+
The team is considering ${title} as an MCP context source. Adopting an MCP server into the workflow
|
|
5636
|
+
is a decision that should be reviewed.
|
|
5637
|
+
|
|
5638
|
+
## Decision
|
|
5639
|
+
|
|
5640
|
+
Consider adopting ${title} MCP as an external context source, documented in \`docs/ai/mcp/\`. This is
|
|
5641
|
+
not accepted until a human reviews and accepts it.
|
|
5642
|
+
|
|
5643
|
+
## Alternatives Considered
|
|
5644
|
+
|
|
5645
|
+
- Do not use this MCP server.
|
|
5646
|
+
- Use a different source for the same context.
|
|
5647
|
+
|
|
5648
|
+
## Consequences
|
|
5649
|
+
|
|
5650
|
+
- The team gains durable, reviewable context from ${title}.
|
|
5651
|
+
- MCP context never overrides accepted repository memory.
|
|
5652
|
+
- Captured context remains proposed until promoted to an ADR.
|
|
5653
|
+
|
|
5654
|
+
## Related Documents
|
|
5655
|
+
|
|
5656
|
+
- \`docs/ai/mcp/${server}.md\` \u2014 captured ${title} MCP context.
|
|
5657
|
+
- \`docs/ai/MCP_STRATEGY.md\` \u2014 how MCP context is captured and ranked.
|
|
5658
|
+
`;
|
|
5659
|
+
}
|
|
5660
|
+
function bullets2(values) {
|
|
5661
|
+
return values.map((value) => `- ${value}`).join("\n");
|
|
5662
|
+
}
|
|
5663
|
+
function titleize2(value) {
|
|
5664
|
+
return value.split("-").filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
4666
5665
|
}
|
|
4667
5666
|
|
|
4668
5667
|
// src/commands/mcp/add.ts
|
|
@@ -4746,7 +5745,7 @@ async function loadConfigOrDefault2(rootDir) {
|
|
|
4746
5745
|
}
|
|
4747
5746
|
|
|
4748
5747
|
// src/core/generator/generate-module.ts
|
|
4749
|
-
import
|
|
5748
|
+
import path16 from "path";
|
|
4750
5749
|
var moduleTemplates = [
|
|
4751
5750
|
{
|
|
4752
5751
|
fileName: "MODULE.md",
|
|
@@ -4819,14 +5818,14 @@ Record durable module decisions here.
|
|
|
4819
5818
|
];
|
|
4820
5819
|
function generateModuleFiles(options) {
|
|
4821
5820
|
const slug = slugify(options.moduleName);
|
|
4822
|
-
const moduleDir =
|
|
5821
|
+
const moduleDir = path16.posix.join(options.modulesDir, slug);
|
|
4823
5822
|
const title = titleizeModuleName(options.moduleName);
|
|
4824
5823
|
const context = createTemplateContext({
|
|
4825
5824
|
slug,
|
|
4826
5825
|
title
|
|
4827
5826
|
});
|
|
4828
5827
|
return moduleTemplates.map((template) => ({
|
|
4829
|
-
path:
|
|
5828
|
+
path: path16.posix.join(moduleDir, template.fileName),
|
|
4830
5829
|
content: renderTemplate(template.content, context)
|
|
4831
5830
|
}));
|
|
4832
5831
|
}
|