@jterrats/open-orchestra 0.1.0 → 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/CHANGELOG.md +53 -0
- package/README.md +17 -2
- package/dist/assets/web-console.js +743 -0
- package/dist/cli.js +157 -4
- package/dist/cli.js.map +1 -1
- package/dist/collaboration-flows.d.ts +5 -0
- package/dist/collaboration-flows.js +256 -0
- package/dist/collaboration-flows.js.map +1 -0
- package/dist/command-manifest.d.ts +11 -0
- package/dist/command-manifest.js +52 -0
- package/dist/command-manifest.js.map +1 -0
- package/dist/commands.d.ts +31 -0
- package/dist/commands.js +644 -2
- package/dist/commands.js.map +1 -1
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +22 -0
- package/dist/constants.js.map +1 -1
- package/dist/defaults.d.ts +7 -11
- package/dist/defaults.js +7 -625
- package/dist/defaults.js.map +1 -1
- package/dist/delegation-decision.d.ts +14 -0
- package/dist/delegation-decision.js +391 -0
- package/dist/delegation-decision.js.map +1 -0
- package/dist/detect-commands.d.ts +3 -0
- package/dist/detect-commands.js +28 -0
- package/dist/detect-commands.js.map +1 -0
- package/dist/diagram-validation.d.ts +36 -0
- package/dist/diagram-validation.js +118 -0
- package/dist/diagram-validation.js.map +1 -0
- package/dist/fs-utils.d.ts +2 -0
- package/dist/fs-utils.js +75 -6
- package/dist/fs-utils.js.map +1 -1
- package/dist/health-checks.d.ts +28 -0
- package/dist/health-checks.js +219 -0
- package/dist/health-checks.js.map +1 -0
- package/dist/health-commands.d.ts +2 -0
- package/dist/health-commands.js +18 -0
- package/dist/health-commands.js.map +1 -0
- package/dist/instruction-apply.d.ts +34 -0
- package/dist/instruction-apply.js +150 -0
- package/dist/instruction-apply.js.map +1 -0
- package/dist/instruction-blocks.d.ts +22 -0
- package/dist/instruction-blocks.js +120 -0
- package/dist/instruction-blocks.js.map +1 -0
- package/dist/instruction-imports.d.ts +12 -0
- package/dist/instruction-imports.js +45 -0
- package/dist/instruction-imports.js.map +1 -0
- package/dist/instruction-stale.d.ts +9 -0
- package/dist/instruction-stale.js +106 -0
- package/dist/instruction-stale.js.map +1 -0
- package/dist/instruction-types.d.ts +66 -0
- package/dist/instruction-types.js +2 -0
- package/dist/instruction-types.js.map +1 -0
- package/dist/instruction-updates.d.ts +4 -0
- package/dist/instruction-updates.js +5 -0
- package/dist/instruction-updates.js.map +1 -0
- package/dist/knowledge-base.d.ts +10 -0
- package/dist/knowledge-base.js +117 -0
- package/dist/knowledge-base.js.map +1 -0
- package/dist/mcp-oauth-proxy.d.ts +39 -0
- package/dist/mcp-oauth-proxy.js +80 -0
- package/dist/mcp-oauth-proxy.js.map +1 -0
- package/dist/pr-review.d.ts +20 -0
- package/dist/pr-review.js +142 -0
- package/dist/pr-review.js.map +1 -0
- package/dist/project-detection.d.ts +22 -0
- package/dist/project-detection.js +174 -0
- package/dist/project-detection.js.map +1 -0
- package/dist/prompt-registry.d.ts +56 -0
- package/dist/prompt-registry.js +163 -0
- package/dist/prompt-registry.js.map +1 -0
- package/dist/release-candidate.d.ts +41 -0
- package/dist/release-candidate.js +196 -0
- package/dist/release-candidate.js.map +1 -0
- package/dist/release-commands.d.ts +4 -0
- package/dist/release-commands.js +50 -0
- package/dist/release-commands.js.map +1 -0
- package/dist/roles/ai-support-roles.d.ts +11 -0
- package/dist/roles/ai-support-roles.js +67 -0
- package/dist/roles/ai-support-roles.js.map +1 -0
- package/dist/roles/core-roles.d.ts +11 -0
- package/dist/roles/core-roles.js +144 -0
- package/dist/roles/core-roles.js.map +1 -0
- package/dist/roles/engineering-roles.d.ts +11 -0
- package/dist/roles/engineering-roles.js +176 -0
- package/dist/roles/engineering-roles.js.map +1 -0
- package/dist/roles/governance-roles.d.ts +11 -0
- package/dist/roles/governance-roles.js +117 -0
- package/dist/roles/governance-roles.js.map +1 -0
- package/dist/roles/index.d.ts +11 -0
- package/dist/roles/index.js +17 -0
- package/dist/roles/index.js.map +1 -0
- package/dist/roles/platform-ops-roles.d.ts +11 -0
- package/dist/roles/platform-ops-roles.js +158 -0
- package/dist/roles/platform-ops-roles.js.map +1 -0
- package/dist/roles/qa-ux-roles.d.ts +11 -0
- package/dist/roles/qa-ux-roles.js +193 -0
- package/dist/roles/qa-ux-roles.js.map +1 -0
- package/dist/roles/release-ops-roles.d.ts +11 -0
- package/dist/roles/release-ops-roles.js +109 -0
- package/dist/roles/release-ops-roles.js.map +1 -0
- package/dist/runtime-adapters.d.ts +6 -0
- package/dist/runtime-adapters.js +88 -0
- package/dist/runtime-adapters.js.map +1 -0
- package/dist/runtime-bootstrap.d.ts +12 -0
- package/dist/runtime-bootstrap.js +85 -0
- package/dist/runtime-bootstrap.js.map +1 -0
- package/dist/skills.d.ts +36 -0
- package/dist/skills.js +665 -0
- package/dist/skills.js.map +1 -0
- package/dist/subagent-protocol.d.ts +41 -0
- package/dist/subagent-protocol.js +179 -0
- package/dist/subagent-protocol.js.map +1 -0
- package/dist/telemetry-consent.d.ts +24 -0
- package/dist/telemetry-consent.js +95 -0
- package/dist/telemetry-consent.js.map +1 -0
- package/dist/telemetry-export.d.ts +14 -0
- package/dist/telemetry-export.js +126 -0
- package/dist/telemetry-export.js.map +1 -0
- package/dist/telemetry-records.d.ts +3 -0
- package/dist/telemetry-records.js +96 -0
- package/dist/telemetry-records.js.map +1 -0
- package/dist/telemetry-redaction.d.ts +9 -0
- package/dist/telemetry-redaction.js +55 -0
- package/dist/telemetry-redaction.js.map +1 -0
- package/dist/telemetry-types.d.ts +52 -0
- package/dist/telemetry-types.js +2 -0
- package/dist/telemetry-types.js.map +1 -0
- package/dist/telemetry.d.ts +4 -0
- package/dist/telemetry.js +4 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/types.d.ts +176 -1
- package/dist/validation.d.ts +3 -1
- package/dist/validation.js +28 -5
- package/dist/validation.js.map +1 -1
- package/dist/web-api.js +167 -3
- package/dist/web-api.js.map +1 -1
- package/dist/web-console.js +6 -160
- package/dist/web-console.js.map +1 -1
- package/dist/workflow-gates.js +4 -2
- package/dist/workflow-gates.js.map +1 -1
- package/dist/workflow-services.js +125 -67
- package/dist/workflow-services.js.map +1 -1
- package/dist/workflow-templates.d.ts +10 -0
- package/dist/workflow-templates.js +141 -0
- package/dist/workflow-templates.js.map +1 -0
- package/dist/workspace-classification.d.ts +5 -0
- package/dist/workspace-classification.js +127 -0
- package/dist/workspace-classification.js.map +1 -0
- package/dist/workspace-validator.js +11 -1
- package/dist/workspace-validator.js.map +1 -1
- package/dist/workspace.d.ts +8 -4
- package/dist/workspace.js +111 -4
- package/dist/workspace.js.map +1 -1
- package/docs/dev-team-specialist-role-profiles.md +171 -0
- package/docs/mcp-oauth-proxy-evaluation.md +44 -0
- package/docs/multi-agent-orchestrator-backlog.md +413 -1
- package/docs/open-orchestra-dogfooding-findings.md +66 -0
- package/docs/orchestra-mvp.md +46 -1
- package/docs/runtime-adapters.md +86 -0
- package/docs/runtime-llm-flow.md +124 -0
- package/docs/setup-agents-dogfooding-findings.md +101 -0
- package/docs/skill-loading-strategy.md +114 -0
- package/docs/source-of-truth-and-agent-learning.md +83 -0
- package/package.json +9 -5
- package/rules/agent-roles.mdc +30 -0
- package/rules/ai-assisted-development.mdc +22 -0
- package/skills/agent-learning/SKILL.md +24 -0
- package/skills/agent-learning/manifest.json +40 -0
- package/skills/backlog-sync/SKILL.md +24 -0
- package/skills/backlog-sync/manifest.json +41 -0
- package/skills/diagram-export/SKILL.md +35 -0
- package/skills/diagram-export/manifest.json +40 -0
- package/skills/model-evaluation/SKILL.md +25 -0
- package/skills/model-evaluation/manifest.json +41 -0
- package/skills/playwright-evidence/SKILL.md +28 -0
- package/skills/playwright-evidence/manifest.json +46 -0
- package/skills/pr-review/SKILL.md +23 -0
- package/skills/pr-review/manifest.json +43 -0
- package/skills/prompt-registry/SKILL.md +24 -0
- package/skills/prompt-registry/manifest.json +45 -0
- package/skills/release-readiness/SKILL.md +25 -0
- package/skills/release-readiness/manifest.json +45 -0
- package/skills/source-of-truth/SKILL.md +24 -0
- package/skills/source-of-truth/manifest.json +47 -0
- package/skills/static-analysis/SKILL.md +26 -0
- package/skills/static-analysis/manifest.json +46 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
const START_PATTERN = /<!-- open-orchestra:start ([^>]+) -->/g;
|
|
4
|
+
const END_PREFIX = '<!-- open-orchestra:end block-id="';
|
|
5
|
+
export function renderManagedInstructionBlock(input) {
|
|
6
|
+
const hash = hashContent(input.content);
|
|
7
|
+
const updatedAt = input.updatedAt ?? new Date().toISOString();
|
|
8
|
+
return [
|
|
9
|
+
`<!-- open-orchestra:start block-id="${input.blockId}" generator="${input.generator}" version="${input.version}" target="${input.target}" source-manifest="${input.sourceManifest}" content-sha256="${hash}" updated-at="${updatedAt}" -->`,
|
|
10
|
+
input.content.trimEnd(),
|
|
11
|
+
`<!-- open-orchestra:end block-id="${input.blockId}" -->`,
|
|
12
|
+
"",
|
|
13
|
+
].join("\n");
|
|
14
|
+
}
|
|
15
|
+
export function upsertManagedInstructionBlock(existing, input, options = {}) {
|
|
16
|
+
const hash = hashContent(input.content);
|
|
17
|
+
const range = findManagedBlock(existing, input.blockId);
|
|
18
|
+
const rendered = renderManagedInstructionBlock({
|
|
19
|
+
...input,
|
|
20
|
+
updatedAt: stableInstructionUpdatedAt(range, hash, input.updatedAt),
|
|
21
|
+
});
|
|
22
|
+
if (!range) {
|
|
23
|
+
const separator = existing.trim() === "" ? "" : existing.endsWith("\n") ? "\n" : "\n\n";
|
|
24
|
+
return {
|
|
25
|
+
content: `${existing}${separator}${rendered}`,
|
|
26
|
+
changed: true,
|
|
27
|
+
drift: false,
|
|
28
|
+
missing: true,
|
|
29
|
+
hash,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const drift = range.actualHash !== range.metadataHash;
|
|
33
|
+
if (drift && !options.force) {
|
|
34
|
+
return {
|
|
35
|
+
content: existing,
|
|
36
|
+
changed: false,
|
|
37
|
+
drift: true,
|
|
38
|
+
missing: false,
|
|
39
|
+
hash,
|
|
40
|
+
existingHash: range.metadataHash,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const content = existing.slice(0, range.start) + rendered + existing.slice(range.end);
|
|
44
|
+
return {
|
|
45
|
+
content,
|
|
46
|
+
changed: content !== existing,
|
|
47
|
+
drift,
|
|
48
|
+
missing: false,
|
|
49
|
+
hash,
|
|
50
|
+
existingHash: range.metadataHash,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function checkManagedInstructionBlock(existing, input) {
|
|
54
|
+
const result = upsertManagedInstructionBlock(existing, input);
|
|
55
|
+
return { ...result, content: existing };
|
|
56
|
+
}
|
|
57
|
+
export async function updateManagedInstructionFile({ filePath, contentPath, input, check = false, dryRun = false, force = false, }) {
|
|
58
|
+
const [existing, content] = await Promise.all([
|
|
59
|
+
readFile(filePath, "utf8").catch(() => ""),
|
|
60
|
+
readFile(contentPath, "utf8"),
|
|
61
|
+
]);
|
|
62
|
+
const blockInput = { ...input, content };
|
|
63
|
+
const result = check
|
|
64
|
+
? checkManagedInstructionBlock(existing, blockInput)
|
|
65
|
+
: upsertManagedInstructionBlock(existing, blockInput, { force });
|
|
66
|
+
if (!check && !dryRun && !result.drift && result.changed) {
|
|
67
|
+
await writeFile(filePath, result.content);
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
export function findManagedBlock(existing, blockId) {
|
|
72
|
+
START_PATTERN.lastIndex = 0;
|
|
73
|
+
let match;
|
|
74
|
+
while ((match = START_PATTERN.exec(existing))) {
|
|
75
|
+
const attributes = parseAttributes(match[1] ?? "");
|
|
76
|
+
if (attributes.get("block-id") !== blockId) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const endMarker = `${END_PREFIX}${blockId}" -->`;
|
|
80
|
+
const contentStart = match.index + match[0].length + 1;
|
|
81
|
+
const endStart = existing.indexOf(endMarker, contentStart);
|
|
82
|
+
if (endStart === -1) {
|
|
83
|
+
throw new Error(`managed block ${blockId} is missing its end marker`);
|
|
84
|
+
}
|
|
85
|
+
const afterEnd = endStart + endMarker.length;
|
|
86
|
+
const managedContent = existing.slice(contentStart, endStart).trimEnd();
|
|
87
|
+
return {
|
|
88
|
+
start: match.index,
|
|
89
|
+
end: existing[afterEnd] === "\n" ? afterEnd + 1 : afterEnd,
|
|
90
|
+
metadataHash: attributes.get("content-sha256") ?? "",
|
|
91
|
+
actualHash: hashContent(managedContent),
|
|
92
|
+
attributes,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
function stableInstructionUpdatedAt(range, nextHash, requestedUpdatedAt) {
|
|
98
|
+
if (requestedUpdatedAt) {
|
|
99
|
+
return requestedUpdatedAt;
|
|
100
|
+
}
|
|
101
|
+
if (range?.metadataHash === nextHash) {
|
|
102
|
+
return range.attributes.get("updated-at") ?? new Date().toISOString();
|
|
103
|
+
}
|
|
104
|
+
return new Date().toISOString();
|
|
105
|
+
}
|
|
106
|
+
function parseAttributes(value) {
|
|
107
|
+
const attributes = new Map();
|
|
108
|
+
for (const match of value.matchAll(/([a-z0-9-]+)="([^"]*)"/g)) {
|
|
109
|
+
const key = match[1];
|
|
110
|
+
const attributeValue = match[2];
|
|
111
|
+
if (key !== undefined && attributeValue !== undefined) {
|
|
112
|
+
attributes.set(key, attributeValue);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return attributes;
|
|
116
|
+
}
|
|
117
|
+
export function hashContent(content) {
|
|
118
|
+
return createHash("sha256").update(content.trimEnd()).digest("hex");
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=instruction-blocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instruction-blocks.js","sourceRoot":"","sources":["../src/instruction-blocks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,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,CAAC,yBAAyB,CAAC,EAAE,CAAC;QAC9D,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,cAAc,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAChC,IAAI,GAAG,KAAK,SAAS,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;YACtD,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InstructionImportEntry, InstructionImportResolution, InstructionTarget } from "./instruction-types.js";
|
|
2
|
+
export declare function parseInstructionImports(content: string): string[];
|
|
3
|
+
export declare function resolveInstructionImports({ entryId, entries, target, }: {
|
|
4
|
+
entryId: string;
|
|
5
|
+
entries: InstructionImportEntry[];
|
|
6
|
+
target: InstructionTarget;
|
|
7
|
+
}): InstructionImportResolution;
|
|
8
|
+
export declare function resolveInstructionImportsFromFile({ registryPath, entryId, target, }: {
|
|
9
|
+
registryPath: string;
|
|
10
|
+
entryId: string;
|
|
11
|
+
target: InstructionTarget;
|
|
12
|
+
}): Promise<InstructionImportResolution>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
const IMPORT_PATTERN = /^\s*@orchestra\/import\s+([a-zA-Z0-9._-]+)\s*$/;
|
|
3
|
+
export function parseInstructionImports(content) {
|
|
4
|
+
return content
|
|
5
|
+
.split("\n")
|
|
6
|
+
.map((line) => line.match(IMPORT_PATTERN)?.[1])
|
|
7
|
+
.filter((value) => Boolean(value));
|
|
8
|
+
}
|
|
9
|
+
export function resolveInstructionImports({ entryId, entries, target, }) {
|
|
10
|
+
const registry = new Map(entries.map((entry) => [entry.id, entry]));
|
|
11
|
+
const importedIds = [];
|
|
12
|
+
const visiting = new Set();
|
|
13
|
+
const visited = new Set();
|
|
14
|
+
const content = resolveEntry(entryId, registry, target, visiting, visited, importedIds);
|
|
15
|
+
return { entryId, target, content, importedIds };
|
|
16
|
+
}
|
|
17
|
+
export async function resolveInstructionImportsFromFile({ registryPath, entryId, target, }) {
|
|
18
|
+
const entries = JSON.parse(await readFile(registryPath, "utf8"));
|
|
19
|
+
return resolveInstructionImports({ entryId, entries, target });
|
|
20
|
+
}
|
|
21
|
+
function resolveEntry(entryId, registry, target, visiting, visited, importedIds) {
|
|
22
|
+
const entry = registry.get(entryId);
|
|
23
|
+
if (!entry) {
|
|
24
|
+
throw new Error(`missing instruction import: ${entryId}`);
|
|
25
|
+
}
|
|
26
|
+
if (visiting.has(entryId)) {
|
|
27
|
+
throw new Error(`cyclic instruction import: ${Array.from(visiting).concat(entryId).join(" -> ")}`);
|
|
28
|
+
}
|
|
29
|
+
const raw = entry.targets?.[target] ?? entry.content;
|
|
30
|
+
visiting.add(entryId);
|
|
31
|
+
const lines = raw.split("\n").flatMap((line) => {
|
|
32
|
+
const imported = line.match(IMPORT_PATTERN)?.[1];
|
|
33
|
+
if (!imported) {
|
|
34
|
+
return [line];
|
|
35
|
+
}
|
|
36
|
+
if (!visited.has(imported)) {
|
|
37
|
+
importedIds.push(imported);
|
|
38
|
+
}
|
|
39
|
+
return resolveEntry(imported, registry, target, visiting, visited, importedIds).split("\n");
|
|
40
|
+
});
|
|
41
|
+
visiting.delete(entryId);
|
|
42
|
+
visited.add(entryId);
|
|
43
|
+
return lines.join("\n");
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=instruction-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instruction-imports.js","sourceRoot":"","sources":["../src/instruction-imports.ts"],"names":[],"mappings":"AAA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AC,CAAC;IACzB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { InstructionFileSpec, InstructionFileStatusReport } from "./instruction-types.js";
|
|
2
|
+
export declare function detectStaleInstructionFiles({ root, specs, }: {
|
|
3
|
+
root?: string;
|
|
4
|
+
specs: InstructionFileSpec[];
|
|
5
|
+
}): Promise<InstructionFileStatusReport>;
|
|
6
|
+
export declare function detectStaleInstructionFilesFromManifest({ root, manifestPath, }: {
|
|
7
|
+
root?: string;
|
|
8
|
+
manifestPath: string;
|
|
9
|
+
}): Promise<InstructionFileStatusReport>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { findManagedBlock, hashContent } from "./instruction-blocks.js";
|
|
4
|
+
export async function detectStaleInstructionFiles({ root = process.cwd(), specs, }) {
|
|
5
|
+
const items = [];
|
|
6
|
+
for (const spec of specs) {
|
|
7
|
+
items.push(await inspectInstructionFile(root, spec));
|
|
8
|
+
}
|
|
9
|
+
return { items, totals: summarizeInstructionStatuses(items) };
|
|
10
|
+
}
|
|
11
|
+
export async function detectStaleInstructionFilesFromManifest({ root = process.cwd(), manifestPath, }) {
|
|
12
|
+
const manifest = JSON.parse(await readFile(manifestPath, "utf8"));
|
|
13
|
+
return detectStaleInstructionFiles({ root, specs: manifest.files ?? [] });
|
|
14
|
+
}
|
|
15
|
+
async function inspectInstructionFile(root, spec) {
|
|
16
|
+
const expectedHash = hashContent(spec.content);
|
|
17
|
+
const resolvedPath = path.resolve(root, spec.filePath);
|
|
18
|
+
let existing;
|
|
19
|
+
try {
|
|
20
|
+
existing = await readFile(resolvedPath, "utf8");
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (error.code === "ENOENT") {
|
|
24
|
+
return {
|
|
25
|
+
filePath: spec.filePath,
|
|
26
|
+
blockId: spec.blockId,
|
|
27
|
+
status: "missing",
|
|
28
|
+
expectedHash,
|
|
29
|
+
reason: "file does not exist",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
const block = findManagedBlock(existing, spec.blockId);
|
|
35
|
+
if (!block) {
|
|
36
|
+
return {
|
|
37
|
+
filePath: spec.filePath,
|
|
38
|
+
blockId: spec.blockId,
|
|
39
|
+
status: existing.includes("open-orchestra:start")
|
|
40
|
+
? "missing"
|
|
41
|
+
: "user-owned",
|
|
42
|
+
expectedHash,
|
|
43
|
+
reason: existing.includes("open-orchestra:start")
|
|
44
|
+
? "managed block is missing from generated file"
|
|
45
|
+
: "file has no Open Orchestra managed marker",
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const common = removeUndefinedInstructionStatus({
|
|
49
|
+
filePath: spec.filePath,
|
|
50
|
+
blockId: spec.blockId,
|
|
51
|
+
expectedHash,
|
|
52
|
+
actualHash: block.actualHash,
|
|
53
|
+
metadataHash: block.metadataHash,
|
|
54
|
+
generator: block.attributes.get("generator"),
|
|
55
|
+
version: block.attributes.get("version"),
|
|
56
|
+
target: block.attributes.get("target"),
|
|
57
|
+
sourceManifest: block.attributes.get("source-manifest"),
|
|
58
|
+
updatedAt: block.attributes.get("updated-at"),
|
|
59
|
+
});
|
|
60
|
+
if (block.actualHash !== block.metadataHash) {
|
|
61
|
+
return {
|
|
62
|
+
...common,
|
|
63
|
+
status: "drifted",
|
|
64
|
+
reason: "managed block content was edited manually",
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (block.metadataHash !== expectedHash) {
|
|
68
|
+
return {
|
|
69
|
+
...common,
|
|
70
|
+
status: "stale",
|
|
71
|
+
reason: "managed block hash differs from current source",
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (common.generator !== spec.generator ||
|
|
75
|
+
common.version !== spec.version ||
|
|
76
|
+
common.target !== spec.target ||
|
|
77
|
+
common.sourceManifest !== spec.sourceManifest) {
|
|
78
|
+
return {
|
|
79
|
+
...common,
|
|
80
|
+
status: "stale",
|
|
81
|
+
reason: "managed block metadata differs from current manifest",
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
...common,
|
|
86
|
+
status: "fresh",
|
|
87
|
+
reason: "managed block matches current source",
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function removeUndefinedInstructionStatus(value) {
|
|
91
|
+
return Object.fromEntries(Object.entries(value).filter((entry) => entry[1] !== undefined));
|
|
92
|
+
}
|
|
93
|
+
function summarizeInstructionStatuses(items) {
|
|
94
|
+
const totals = {
|
|
95
|
+
fresh: 0,
|
|
96
|
+
stale: 0,
|
|
97
|
+
drifted: 0,
|
|
98
|
+
missing: 0,
|
|
99
|
+
"user-owned": 0,
|
|
100
|
+
};
|
|
101
|
+
for (const item of items) {
|
|
102
|
+
totals[item.status] += 1;
|
|
103
|
+
}
|
|
104
|
+
return totals;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=instruction-stale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instruction-stale.js","sourceRoot":"","sources":["../src/instruction-stale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAOxE,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAAC,EAChD,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,EACpB,KAAK,GAIN;IACC,MAAM,KAAK,GAAgC,EAAE,CAAC;IAC9C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,MAAM,sBAAsB,CAAC,IAAI,EAAE,I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AAC,SAAS;QACnC,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO;QAC/B,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;QAC7B,MAAM,CAAC,cAAc,KAAK,IAAI,CAAC,cAAc,EAC7C,CAAC;QACD,OAAO;YACL,GAAG,MAAM;YACT,MAAM,EAAE,OAAO;YACf,MAAM,EAAE,sDAAsD;SAC/D,CAAC;IACJ,CAAC;IACD,OAAO;QACL,GAAG,MAAM;QACT,MAAM,EAAE,OAAO;QACf,MAAM,EAAE,sCAAsC;KAC/C,CAAC;AACJ,CAAC;AAED,SAAS,gCAAgC,CACvC,KAA8B;IAE9B,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CACR,CAAC;AAC5D,CAAC;AACD,SAAS,4BAA4B,CACnC,KAAkC;IAElC,MAAM,MAAM,GAA0C;QACpD,KAAK,EAAE,CAAC;QACR,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,YAAY,EAAE,CAAC;KAChB,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export type InstructionTarget = "generic" | "claude" | "cursor" | "codex" | "vscode" | "windsurf";
|
|
2
|
+
export type InstructionFileStatus = "fresh" | "stale" | "drifted" | "missing" | "user-owned";
|
|
3
|
+
export interface InstructionFileSpec {
|
|
4
|
+
filePath: string;
|
|
5
|
+
blockId: string;
|
|
6
|
+
generator: string;
|
|
7
|
+
version: string;
|
|
8
|
+
target: InstructionTarget;
|
|
9
|
+
sourceManifest: string;
|
|
10
|
+
content: string;
|
|
11
|
+
}
|
|
12
|
+
export interface InstructionFileMetadata {
|
|
13
|
+
blockId: string;
|
|
14
|
+
generator: string;
|
|
15
|
+
version: string;
|
|
16
|
+
target: InstructionTarget;
|
|
17
|
+
sourceManifest: string;
|
|
18
|
+
contentHash: string;
|
|
19
|
+
updatedAt: string;
|
|
20
|
+
}
|
|
21
|
+
export interface InstructionFileStatusItem {
|
|
22
|
+
filePath: string;
|
|
23
|
+
blockId: string;
|
|
24
|
+
status: InstructionFileStatus;
|
|
25
|
+
expectedHash: string;
|
|
26
|
+
actualHash?: string;
|
|
27
|
+
metadataHash?: string;
|
|
28
|
+
generator?: string;
|
|
29
|
+
version?: string;
|
|
30
|
+
target?: string;
|
|
31
|
+
sourceManifest?: string;
|
|
32
|
+
updatedAt?: string;
|
|
33
|
+
reason: string;
|
|
34
|
+
}
|
|
35
|
+
export interface InstructionFileStatusReport {
|
|
36
|
+
items: InstructionFileStatusItem[];
|
|
37
|
+
totals: Record<InstructionFileStatus, number>;
|
|
38
|
+
}
|
|
39
|
+
export interface ManagedInstructionBlockInput {
|
|
40
|
+
blockId: string;
|
|
41
|
+
generator: string;
|
|
42
|
+
version: string;
|
|
43
|
+
target: InstructionTarget;
|
|
44
|
+
sourceManifest: string;
|
|
45
|
+
content: string;
|
|
46
|
+
updatedAt?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ManagedInstructionBlockResult {
|
|
49
|
+
content: string;
|
|
50
|
+
changed: boolean;
|
|
51
|
+
drift: boolean;
|
|
52
|
+
missing: boolean;
|
|
53
|
+
hash: string;
|
|
54
|
+
existingHash?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface InstructionImportEntry {
|
|
57
|
+
id: string;
|
|
58
|
+
content: string;
|
|
59
|
+
targets?: Partial<Record<InstructionTarget, string>>;
|
|
60
|
+
}
|
|
61
|
+
export interface InstructionImportResolution {
|
|
62
|
+
entryId: string;
|
|
63
|
+
target: InstructionTarget;
|
|
64
|
+
content: string;
|
|
65
|
+
importedIds: string[];
|
|
66
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instruction-types.js","sourceRoot":"","sources":["../src/instruction-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instruction-updates.js","sourceRoot":"","sources":["../src/instruction-updates.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface SourceOfTruthEntry {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
priority: number;
|
|
6
|
+
locations: string[];
|
|
7
|
+
useWhen: string[];
|
|
8
|
+
verification: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function defaultSourceOfTruthCatalog(): SourceOfTruthEntry[];
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export function defaultSourceOfTruthCatalog() {
|
|
2
|
+
return [
|
|
3
|
+
{
|
|
4
|
+
id: "project-instructions",
|
|
5
|
+
name: "Project Instructions",
|
|
6
|
+
description: "Always-loaded project instructions and local agent operating rules.",
|
|
7
|
+
priority: 1,
|
|
8
|
+
locations: ["AGENTS.md", "ORCHESTRA.md", "CLAUDE.md", "rules/*.mdc"],
|
|
9
|
+
useWhen: [
|
|
10
|
+
"before planning",
|
|
11
|
+
"before implementation",
|
|
12
|
+
"before final response",
|
|
13
|
+
],
|
|
14
|
+
verification: "Prefer the most specific local instruction file for the current tool or agent.",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: "product-backlog",
|
|
18
|
+
name: "Product Backlog",
|
|
19
|
+
description: "User stories, acceptance criteria, tasks, and workflow state.",
|
|
20
|
+
priority: 2,
|
|
21
|
+
locations: [
|
|
22
|
+
"docs/multi-agent-orchestrator-backlog.md",
|
|
23
|
+
".agent-workflow/tasks.json",
|
|
24
|
+
"GitHub issues",
|
|
25
|
+
],
|
|
26
|
+
useWhen: ["before scope decisions", "before implementation", "before QA"],
|
|
27
|
+
verification: "Confirm the backlog item and acceptance criteria before starting work.",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "architecture",
|
|
31
|
+
name: "Architecture and Design",
|
|
32
|
+
description: "Architecture docs, ADRs, diagrams, service boundaries, and integration contracts.",
|
|
33
|
+
priority: 3,
|
|
34
|
+
locations: [
|
|
35
|
+
"docs/*.md",
|
|
36
|
+
".agent-workflow/decisions/",
|
|
37
|
+
".generated-prompts/diagrams.md",
|
|
38
|
+
],
|
|
39
|
+
useWhen: ["before non-trivial design", "before cross-module changes"],
|
|
40
|
+
verification: "Record architecture conflicts as decisions or blockers.",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "codebase",
|
|
44
|
+
name: "Codebase",
|
|
45
|
+
description: "Source code, tests, package manifests, config, and local command contracts.",
|
|
46
|
+
priority: 4,
|
|
47
|
+
locations: ["src/", "test/", "package.json", "tsconfig.json"],
|
|
48
|
+
useWhen: ["before code changes", "before refactors", "before tests"],
|
|
49
|
+
verification: "Inspect existing patterns before adding new abstractions or dependencies.",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: "quality-security",
|
|
53
|
+
name: "Quality and Security",
|
|
54
|
+
description: "Static analysis, hooks, scans, QA plans, and test evidence.",
|
|
55
|
+
priority: 5,
|
|
56
|
+
locations: [
|
|
57
|
+
".githooks/",
|
|
58
|
+
".agent-workflow/evidence/",
|
|
59
|
+
"test/",
|
|
60
|
+
"playwright.config.*",
|
|
61
|
+
],
|
|
62
|
+
useWhen: ["before commit", "before release", "before risk review"],
|
|
63
|
+
verification: "Use local commands and evidence artifacts as proof, not generated explanations.",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "devops-runtime",
|
|
67
|
+
name: "DevOps and Runtime",
|
|
68
|
+
description: "CI/CD, deployment, IaC, observability, rollback, and release artifacts.",
|
|
69
|
+
priority: 6,
|
|
70
|
+
locations: [
|
|
71
|
+
".github/workflows/",
|
|
72
|
+
"infra/",
|
|
73
|
+
"docs/*release*.md",
|
|
74
|
+
"docs/*runbook*.md",
|
|
75
|
+
],
|
|
76
|
+
useWhen: [
|
|
77
|
+
"before workflow changes",
|
|
78
|
+
"before deploy",
|
|
79
|
+
"before release readiness",
|
|
80
|
+
],
|
|
81
|
+
verification: "Validate downtime, rollback, secrets, environment isolation, and observability impact.",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
id: "vendor-docs",
|
|
85
|
+
name: "Official Vendor Documentation",
|
|
86
|
+
description: "Official provider, framework, package, cloud, and browser documentation.",
|
|
87
|
+
priority: 7,
|
|
88
|
+
locations: ["official documentation URLs recorded by task"],
|
|
89
|
+
useWhen: [
|
|
90
|
+
"current APIs",
|
|
91
|
+
"provider behavior",
|
|
92
|
+
"framework behavior",
|
|
93
|
+
"cloud/runtime behavior",
|
|
94
|
+
],
|
|
95
|
+
verification: "Use primary official docs and record source URLs for material claims.",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: "agent-memory",
|
|
99
|
+
name: "Agent Memory",
|
|
100
|
+
description: "Prompt registry, handoffs, evidence, decisions, events, and lessons learned.",
|
|
101
|
+
priority: 8,
|
|
102
|
+
locations: [
|
|
103
|
+
".generated-prompts/",
|
|
104
|
+
".agent-workflow/events.jsonl",
|
|
105
|
+
".agent-workflow/agent-lessons.jsonl",
|
|
106
|
+
".agent-workflow/handoffs/",
|
|
107
|
+
],
|
|
108
|
+
useWhen: [
|
|
109
|
+
"before repeated operations",
|
|
110
|
+
"before handoff",
|
|
111
|
+
"before final summary",
|
|
112
|
+
],
|
|
113
|
+
verification: "Load only relevant entries for the current task, skill, tool, or error signature.",
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=knowledge-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge-base.js","sourceRoot":"","sources":["../src/knowledge-base.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,2BAA2B;IACzC,OAAO;QACL;YACE,EAAE,EAAE,sBAAsB;YAC1B,IAAI,EAAE,sBAAsB;YAC5B,WAAW,EACT,qEAAqE;YACvE,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,CAAC,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,CAAC;YACpE,OAAO,EAAE;gBACP,iBAAiB;gBACjB,uBAAuB;gBACvB,uBAAuB;aACxB;YACD,YAAY,EACV,gFAAgF;SACnF;QACD;YACE,EAAE,EAAE,iBAAiB;YACrB,IAAI,EAAE,iBAAiB;YACvB,WAAW,EACT,+DAA+D;YACjE,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE;gBACT,0CAA0C;gBAC1C,4BAA4B;gBAC5B,eAAe;aAChB;YACD,OAAO,EAAE,CAAC,wBAAwB,EAAE,uBAAuB,EAAE,WAAW,CAAC;YACzE,YAAY,EACV,wEAAwE;SAC3E;QACD;YACE,EAAE,EAAE,cAAc;YAClB,IAAI,EAAE,yBAAyB;YAC/B,WAAW,EACT,mFAAmF;YACrF,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE;gBACT,WAAW;gBACX,4BAA4B;gBAC5B,gCAAgC;aACjC;YACD,OAAO,EAAE,CAAC,2BAA2B,EAAE,6BAA6B,CAAC;YACrE,YAAY,EAAE,yDAAyD;SACxE;QACD;YACE,EAAE,EAAE,UAAU;YACd,IAAI,EAAE,UAAU;YAChB,WAAW,EACT,6EAA6E;YAC/E,QAAQ,EAAE,CAAC;YACX,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,CAAC;YAC7D,OAAO,EAAE,CAAC,qBAAqB,EAAE,kBAAkB,EAAE,cAAc,CAAC;YACpE,YAAY,EACV,2EAA2E;SAC9E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|
2
|
+
export type McpSecretStorage = "keychain" | "libsecret" | "windows-credential" | "secure-file";
|
|
3
|
+
export interface McpOAuthProxyConfig {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
mode: McpProxyMode;
|
|
6
|
+
serverUrl: string;
|
|
7
|
+
tokenStorage: McpSecretStorage;
|
|
8
|
+
tokenPath?: string;
|
|
9
|
+
refreshWindowSeconds: number;
|
|
10
|
+
approvedBy?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface McpProxyEvaluation {
|
|
13
|
+
approved: boolean;
|
|
14
|
+
risks: string[];
|
|
15
|
+
recommendations: string[];
|
|
16
|
+
modes: {
|
|
17
|
+
mode: McpProxyMode;
|
|
18
|
+
summary: string;
|
|
19
|
+
tradeOff: string;
|
|
20
|
+
}[];
|
|
21
|
+
}
|
|
22
|
+
export interface McpTokenState {
|
|
23
|
+
accessToken: string;
|
|
24
|
+
refreshToken: string;
|
|
25
|
+
expiresAt: string;
|
|
26
|
+
}
|
|
27
|
+
export interface McpTokenRefreshResult {
|
|
28
|
+
refreshed: boolean;
|
|
29
|
+
reason: string;
|
|
30
|
+
token: McpTokenState;
|
|
31
|
+
}
|
|
32
|
+
export declare function evaluateMcpOAuthProxy(config: McpOAuthProxyConfig): McpProxyEvaluation;
|
|
33
|
+
export declare function validateMcpOAuthProxyConfig(config: McpOAuthProxyConfig): string[];
|
|
34
|
+
export declare function refreshMcpTokenIfNeeded({ token, now, refreshWindowSeconds, refresh, }: {
|
|
35
|
+
token: McpTokenState;
|
|
36
|
+
now?: Date;
|
|
37
|
+
refreshWindowSeconds: number;
|
|
38
|
+
refresh: (token: McpTokenState) => Promise<McpTokenState>;
|
|
39
|
+
}): Promise<McpTokenRefreshResult>;
|