agentplane 0.3.13 → 0.3.15
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/assets/RUNNER.md +1 -1
- package/assets/agents/ORCHESTRATOR.json +1 -1
- package/assets/agents/SKILL_EXTRACTOR.json +31 -0
- package/assets/framework.manifest.json +7 -0
- package/assets/policy/incidents.md +5 -3
- package/assets/policy/workflow.branch_pr.md +10 -5
- package/dist/.build-manifest.json +280 -180
- package/dist/cli/output.d.ts +29 -0
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +33 -0
- package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/core.js +29 -87
- package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/lifecycle.js +4 -12
- package/dist/cli/run-cli/command-catalog/project.d.ts +1 -1
- package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/project.js +16 -38
- package/dist/cli/run-cli/command-catalog/shared.d.ts +9 -6
- package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/shared.js +23 -6
- package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
- package/dist/cli/run-cli/command-catalog/task.js +6 -18
- package/dist/cli/run-cli/command-catalog.d.ts +1 -1
- package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/recipes.d.ts.map +1 -1
- package/dist/cli/run-cli/commands/init/recipes.js +1 -0
- package/dist/cli/run-cli.js +1 -1
- package/dist/cli/run-cli.test-helpers.d.ts +1 -74
- package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
- package/dist/cli/run-cli.test-helpers.js +1 -769
- package/dist/commands/branch/cleanup-merged.d.ts.map +1 -1
- package/dist/commands/branch/cleanup-merged.js +5 -9
- package/dist/commands/branch/work-start.command.d.ts.map +1 -1
- package/dist/commands/branch/work-start.command.js +1 -0
- package/dist/commands/commit.spec.d.ts.map +1 -1
- package/dist/commands/commit.spec.js +2 -0
- package/dist/commands/doctor/branch-pr.d.ts +1 -1
- package/dist/commands/doctor/branch-pr.d.ts.map +1 -1
- package/dist/commands/doctor/branch-pr.js +5 -2
- package/dist/commands/guard/impl/commands.d.ts.map +1 -1
- package/dist/commands/guard/impl/commands.js +4 -1
- package/dist/commands/guard/impl/comment-commit.d.ts.map +1 -1
- package/dist/commands/guard/impl/comment-commit.js +2 -1
- package/dist/commands/guard/impl/env.d.ts +6 -0
- package/dist/commands/guard/impl/env.d.ts.map +1 -1
- package/dist/commands/guard/impl/env.js +41 -0
- package/dist/commands/pr/internal/auto-commit.d.ts.map +1 -1
- package/dist/commands/pr/internal/auto-commit.js +2 -1
- package/dist/commands/pr/internal/sync-branch.d.ts +36 -0
- package/dist/commands/pr/internal/sync-branch.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-branch.js +113 -0
- package/dist/commands/pr/internal/sync-github.d.ts +28 -0
- package/dist/commands/pr/internal/sync-github.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-github.js +178 -0
- package/dist/commands/pr/internal/sync-model.d.ts +36 -0
- package/dist/commands/pr/internal/sync-model.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-model.js +1 -0
- package/dist/commands/pr/internal/sync-open-step.d.ts +10 -0
- package/dist/commands/pr/internal/sync-open-step.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-open-step.js +128 -0
- package/dist/commands/pr/internal/sync-support.d.ts +7 -0
- package/dist/commands/pr/internal/sync-support.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-support.js +29 -0
- package/dist/commands/pr/internal/sync-update-step.d.ts +6 -0
- package/dist/commands/pr/internal/sync-update-step.d.ts.map +1 -0
- package/dist/commands/pr/internal/sync-update-step.js +68 -0
- package/dist/commands/pr/internal/sync.d.ts +2 -6
- package/dist/commands/pr/internal/sync.d.ts.map +1 -1
- package/dist/commands/pr/internal/sync.js +83 -529
- package/dist/commands/pr/open.d.ts.map +1 -1
- package/dist/commands/pr/open.js +25 -8
- package/dist/commands/pr/pr.command.d.ts.map +1 -1
- package/dist/commands/pr/pr.command.js +7 -2
- package/dist/commands/recipes/impl/apply.d.ts +1 -1
- package/dist/commands/recipes/impl/apply.d.ts.map +1 -1
- package/dist/commands/recipes/impl/apply.js +1 -2
- package/dist/commands/recipes/impl/commands/active.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/active.js +6 -5
- package/dist/commands/recipes/impl/commands/add.d.ts +1 -0
- package/dist/commands/recipes/impl/commands/add.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/add.js +32 -27
- package/dist/commands/recipes/impl/commands/detach.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/detach.js +35 -21
- package/dist/commands/recipes/impl/commands/disable.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/disable.js +5 -3
- package/dist/commands/recipes/impl/commands/enable.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/enable.js +5 -3
- package/dist/commands/recipes/impl/commands/explain.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/explain.js +57 -47
- package/dist/commands/recipes/impl/commands/info.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/info.js +25 -21
- package/dist/commands/recipes/impl/commands/install.d.ts +1 -1
- package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/install.js +3 -13
- package/dist/commands/recipes/impl/commands/list-remote.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/list-remote.js +2 -3
- package/dist/commands/recipes/impl/commands/list.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/list.js +7 -6
- package/dist/commands/recipes/impl/commands/remove.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/remove.js +12 -7
- package/dist/commands/recipes/impl/commands/update.d.ts.map +1 -1
- package/dist/commands/recipes/impl/commands/update.js +38 -24
- package/dist/commands/recipes/impl/index.d.ts +1 -1
- package/dist/commands/recipes/impl/index.d.ts.map +1 -1
- package/dist/commands/recipes/impl/installed-recipes.d.ts +1 -1
- package/dist/commands/recipes/impl/installed-recipes.d.ts.map +1 -1
- package/dist/commands/recipes/impl/installed-recipes.js +1 -2
- package/dist/commands/recipes/impl/mutation-transaction.d.ts +7 -0
- package/dist/commands/recipes/impl/mutation-transaction.d.ts.map +1 -0
- package/dist/commands/recipes/impl/mutation-transaction.js +47 -0
- package/dist/commands/recipes/impl/overlay-project.d.ts +19 -3
- package/dist/commands/recipes/impl/overlay-project.d.ts.map +1 -1
- package/dist/commands/recipes/impl/overlay-project.js +76 -38
- package/dist/commands/recipes/impl/paths.d.ts +0 -3
- package/dist/commands/recipes/impl/paths.d.ts.map +1 -1
- package/dist/commands/recipes/impl/paths.js +0 -3
- package/dist/commands/recipes/impl/project-installed-recipes.d.ts +4 -1
- package/dist/commands/recipes/impl/project-installed-recipes.d.ts.map +1 -1
- package/dist/commands/recipes/impl/project-installed-recipes.js +6 -4
- package/dist/commands/recipes/impl/project-recipe-state.d.ts +1 -1
- package/dist/commands/recipes/impl/project-recipe-state.d.ts.map +1 -1
- package/dist/commands/recipes/impl/project-registry.d.ts +5 -1
- package/dist/commands/recipes/impl/project-registry.d.ts.map +1 -1
- package/dist/commands/recipes/impl/project-registry.js +34 -14
- package/dist/commands/recipes/impl/resolver.d.ts +1 -1
- package/dist/commands/recipes/impl/resolver.d.ts.map +1 -1
- package/dist/commands/recipes/impl/resolver.js +1 -1
- package/dist/commands/recipes/impl/types.d.ts +1 -1
- package/dist/commands/recipes/impl/types.d.ts.map +1 -1
- package/dist/commands/recipes/impl/version.d.ts +5 -0
- package/dist/commands/recipes/impl/version.d.ts.map +1 -0
- package/dist/commands/recipes/impl/version.js +9 -0
- package/dist/commands/recipes.d.ts +5 -4
- package/dist/commands/recipes.d.ts.map +1 -1
- package/dist/commands/recipes.js +3 -3
- package/dist/commands/release/apply.command.d.ts +1 -1
- package/dist/commands/release/apply.command.d.ts.map +1 -1
- package/dist/commands/release/apply.command.js +15 -379
- package/dist/commands/release/apply.mutation.d.ts +1 -0
- package/dist/commands/release/apply.mutation.d.ts.map +1 -1
- package/dist/commands/release/apply.mutation.js +24 -1
- package/dist/commands/release/apply.pipeline.d.ts +22 -0
- package/dist/commands/release/apply.pipeline.d.ts.map +1 -0
- package/dist/commands/release/apply.pipeline.js +371 -0
- package/dist/commands/release/apply.preflight.d.ts +2 -0
- package/dist/commands/release/apply.preflight.d.ts.map +1 -1
- package/dist/commands/release/apply.preflight.js +13 -4
- package/dist/commands/release/apply.types.d.ts +27 -0
- package/dist/commands/release/apply.types.d.ts.map +1 -1
- package/dist/commands/release.test-helpers.d.ts +4 -0
- package/dist/commands/release.test-helpers.d.ts.map +1 -1
- package/dist/commands/release.test-helpers.js +7 -0
- package/dist/commands/shared/reconcile-check.d.ts.map +1 -1
- package/dist/commands/shared/reconcile-check.js +2 -2
- package/dist/commands/shared/task-backend.d.ts +6 -1
- package/dist/commands/shared/task-backend.d.ts.map +1 -1
- package/dist/commands/shared/task-backend.js +34 -2
- package/dist/commands/shared/task-mutation.d.ts.map +1 -1
- package/dist/commands/shared/task-mutation.js +4 -4
- package/dist/commands/shared/task-store/intents.d.ts +34 -0
- package/dist/commands/shared/task-store/intents.d.ts.map +1 -0
- package/dist/commands/shared/task-store/intents.js +265 -0
- package/dist/commands/shared/task-store/readme.d.ts +28 -0
- package/dist/commands/shared/task-store/readme.d.ts.map +1 -0
- package/dist/commands/shared/task-store/readme.js +125 -0
- package/dist/commands/shared/task-store/store.d.ts +26 -0
- package/dist/commands/shared/task-store/store.d.ts.map +1 -0
- package/dist/commands/shared/task-store/store.js +105 -0
- package/dist/commands/shared/task-store/types.d.ts +94 -0
- package/dist/commands/shared/task-store/types.d.ts.map +1 -0
- package/dist/commands/shared/task-store/types.js +1 -0
- package/dist/commands/shared/task-store.d.ts +3 -109
- package/dist/commands/shared/task-store.d.ts.map +1 -1
- package/dist/commands/shared/task-store.js +2 -493
- package/dist/commands/task/block.d.ts.map +1 -1
- package/dist/commands/task/block.js +7 -2
- package/dist/commands/task/comment.d.ts.map +1 -1
- package/dist/commands/task/comment.js +7 -2
- package/dist/commands/task/finish-shared.d.ts.map +1 -1
- package/dist/commands/task/finish-shared.js +3 -3
- package/dist/commands/task/finish.d.ts.map +1 -1
- package/dist/commands/task/finish.js +102 -15
- package/dist/commands/task/hosted-close.command.d.ts.map +1 -1
- package/dist/commands/task/hosted-close.command.js +23 -2
- package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
- package/dist/commands/task/hosted-merge-sync.js +9 -4
- package/dist/commands/task/list.run.d.ts.map +1 -1
- package/dist/commands/task/list.run.js +14 -4
- package/dist/commands/task/new.command.d.ts.map +1 -1
- package/dist/commands/task/new.command.js +16 -2
- package/dist/commands/task/new.js +2 -2
- package/dist/commands/task/show.d.ts.map +1 -1
- package/dist/commands/task/show.js +3 -3
- package/dist/commands/task/update.d.ts.map +1 -1
- package/dist/commands/task/update.js +11 -3
- package/dist/runner/adapters/codex.d.ts.map +1 -1
- package/dist/runner/adapters/codex.js +3 -33
- package/dist/runner/adapters/custom.d.ts.map +1 -1
- package/dist/runner/adapters/custom.js +3 -30
- package/dist/runner/adapters/runtime-shared.d.ts +14 -0
- package/dist/runner/adapters/runtime-shared.d.ts.map +1 -0
- package/dist/runner/adapters/runtime-shared.js +36 -0
- package/dist/runner/context/base-prompt-sources.d.ts +30 -0
- package/dist/runner/context/base-prompt-sources.d.ts.map +1 -0
- package/dist/runner/context/base-prompt-sources.js +144 -0
- package/dist/runner/context/base-prompts.d.ts +3 -22
- package/dist/runner/context/base-prompts.d.ts.map +1 -1
- package/dist/runner/context/base-prompts.js +6 -450
- package/dist/runner/context/overlay-prompt-blocks.d.ts +7 -0
- package/dist/runner/context/overlay-prompt-blocks.d.ts.map +1 -0
- package/dist/runner/context/overlay-prompt-blocks.js +72 -0
- package/dist/runner/context/prompt-block-shared.d.ts +54 -0
- package/dist/runner/context/prompt-block-shared.d.ts.map +1 -0
- package/dist/runner/context/prompt-block-shared.js +106 -0
- package/dist/runner/context/recipe-context.d.ts +2 -1
- package/dist/runner/context/recipe-context.d.ts.map +1 -1
- package/dist/runner/context/recipe-context.js +2 -1
- package/dist/runner/context/recipe-prompt-blocks.d.ts +6 -0
- package/dist/runner/context/recipe-prompt-blocks.d.ts.map +1 -0
- package/dist/runner/context/recipe-prompt-blocks.js +143 -0
- package/dist/runner/usecases/scenario-materialize-task.js +2 -2
- package/dist/runner/usecases/task-run-inspect.js +2 -2
- package/dist/runner/usecases/task-run-lifecycle-shared.js +2 -2
- package/dist/runner/usecases/task-run.d.ts.map +1 -1
- package/dist/runner/usecases/task-run.js +4 -2
- package/dist/runtime/capabilities/recipe.d.ts +1 -1
- package/dist/runtime/capabilities/recipe.d.ts.map +1 -1
- package/dist/runtime/execution-context.d.ts +63 -0
- package/dist/runtime/execution-context.d.ts.map +1 -0
- package/dist/{usecases/context/resolve-context.js → runtime/execution-context.js} +23 -26
- package/dist/runtime/incidents/advice-strategy.d.ts +15 -0
- package/dist/runtime/incidents/advice-strategy.d.ts.map +1 -0
- package/dist/runtime/incidents/advice-strategy.js +54 -0
- package/dist/runtime/incidents/plan-strategy.d.ts +9 -0
- package/dist/runtime/incidents/plan-strategy.d.ts.map +1 -0
- package/dist/runtime/incidents/plan-strategy.js +205 -0
- package/dist/runtime/incidents/registry-strategy.d.ts +6 -0
- package/dist/runtime/incidents/registry-strategy.d.ts.map +1 -0
- package/dist/runtime/incidents/registry-strategy.js +280 -0
- package/dist/runtime/incidents/resolve.d.ts +3 -25
- package/dist/runtime/incidents/resolve.d.ts.map +1 -1
- package/dist/runtime/incidents/resolve.js +3 -683
- package/dist/runtime/incidents/shared.d.ts +34 -0
- package/dist/runtime/incidents/shared.d.ts.map +1 -0
- package/dist/runtime/incidents/shared.js +171 -0
- package/dist/testing/cli-harness/recipe-archives.d.ts +28 -0
- package/dist/testing/cli-harness/recipe-archives.d.ts.map +1 -0
- package/dist/testing/cli-harness/recipe-archives.js +374 -0
- package/dist/testing/cli-harness/stdio.d.ts +26 -0
- package/dist/testing/cli-harness/stdio.d.ts.map +1 -0
- package/dist/testing/cli-harness/stdio.js +84 -0
- package/dist/testing/cli-harness.d.ts +25 -0
- package/dist/testing/cli-harness.d.ts.map +1 -0
- package/dist/testing/cli-harness.js +313 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +1 -0
- package/package.json +7 -4
- package/dist/commands/recipes/impl/manifest.d.ts +0 -4
- package/dist/commands/recipes/impl/manifest.d.ts.map +0 -1
- package/dist/commands/recipes/impl/manifest.js +0 -7
- package/dist/commands/recipes/impl/normalize.d.ts +0 -8
- package/dist/commands/recipes/impl/normalize.d.ts.map +0 -1
- package/dist/commands/recipes/impl/normalize.js +0 -54
- package/dist/commands/recipes/impl/scenario.d.ts +0 -16
- package/dist/commands/recipes/impl/scenario.d.ts.map +0 -1
- package/dist/commands/recipes/impl/scenario.js +0 -262
- package/dist/recipes/bundled-recipes.d.ts +0 -17
- package/dist/recipes/bundled-recipes.d.ts.map +0 -1
- package/dist/recipes/bundled-recipes.js +0 -15
- package/dist/usecases/context/resolve-context.d.ts +0 -68
- package/dist/usecases/context/resolve-context.d.ts.map +0 -1
- package/dist/usecases/task/task-list-usecase.d.ts +0 -9
- package/dist/usecases/task/task-list-usecase.d.ts.map +0 -1
- package/dist/usecases/task/task-list-usecase.js +0 -17
- package/dist/usecases/task/task-new-usecase.d.ts +0 -9
- package/dist/usecases/task/task-new-usecase.d.ts.map +0 -1
- package/dist/usecases/task/task-new-usecase.js +0 -17
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { buildDerivedIncidentRule, buildIncidentFingerprint, buildMatchTerms, dedupeCaseInsensitive, normalizeLines, parseBoolean, parseCsvList, parseFixability, resolveIncidentState, summarizeTaskScope, appendFieldValue, normalizeKey, } from "./shared.js";
|
|
2
|
+
import { appendIncidentRegistryEntries, createIncidentRegistrySkeleton, parseIncidentRegistry, } from "./registry-strategy.js";
|
|
3
|
+
export function extractIncidentCandidatesFromFindings(findings) {
|
|
4
|
+
return parseIncidentFindingBlocks(findings)
|
|
5
|
+
.filter((candidate) => candidate.shouldPromote)
|
|
6
|
+
.map(({ shouldPromote: _shouldPromote, ...candidate }) => candidate);
|
|
7
|
+
}
|
|
8
|
+
function parseIncidentFindingBlocks(findings) {
|
|
9
|
+
const lines = normalizeLines(findings);
|
|
10
|
+
const candidates = [];
|
|
11
|
+
let currentFields = null;
|
|
12
|
+
let currentLine = 0;
|
|
13
|
+
let currentKey = null;
|
|
14
|
+
const flush = () => {
|
|
15
|
+
if (!currentFields)
|
|
16
|
+
return;
|
|
17
|
+
const promotion = currentFields.promotion?.trim() || null;
|
|
18
|
+
const fixability = parseFixability(currentFields.fixability);
|
|
19
|
+
const incidentExternal = parseBoolean(currentFields.incidentexternal) || fixability === "external";
|
|
20
|
+
const incidentInternal = parseBoolean(currentFields.incidentinternal) || fixability === "repo-fixable";
|
|
21
|
+
const shouldPromote = promotion?.toLowerCase() === "incident-candidate" || incidentExternal || incidentInternal;
|
|
22
|
+
const observation = currentFields.observation?.trim() ?? "";
|
|
23
|
+
if (!observation) {
|
|
24
|
+
currentFields = null;
|
|
25
|
+
currentKey = null;
|
|
26
|
+
currentLine = 0;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
candidates.push({
|
|
30
|
+
observation,
|
|
31
|
+
impact: currentFields.impact?.trim() || null,
|
|
32
|
+
resolution: currentFields.resolution?.trim() || null,
|
|
33
|
+
promotion,
|
|
34
|
+
incidentScope: currentFields.incidentscope?.trim() || null,
|
|
35
|
+
incidentRule: currentFields.incidentrule?.trim() || null,
|
|
36
|
+
incidentAdvice: currentFields.incidentadvice?.trim() || null,
|
|
37
|
+
incidentTags: parseCsvList(currentFields.incidenttags),
|
|
38
|
+
incidentMatch: parseCsvList(currentFields.incidentmatch),
|
|
39
|
+
incidentExternal,
|
|
40
|
+
incidentInternal,
|
|
41
|
+
fixability,
|
|
42
|
+
shouldPromote,
|
|
43
|
+
line: currentLine,
|
|
44
|
+
rawFields: { ...currentFields },
|
|
45
|
+
});
|
|
46
|
+
currentFields = null;
|
|
47
|
+
currentKey = null;
|
|
48
|
+
currentLine = 0;
|
|
49
|
+
};
|
|
50
|
+
for (const [index, line] of lines.entries()) {
|
|
51
|
+
const observationMatch = /^\s*-\s+Observation:\s*(.*?)\s*$/.exec(line);
|
|
52
|
+
if (observationMatch) {
|
|
53
|
+
flush();
|
|
54
|
+
currentFields = { observation: observationMatch[1] ?? "" };
|
|
55
|
+
currentKey = "observation";
|
|
56
|
+
currentLine = index + 1;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (!currentFields)
|
|
60
|
+
continue;
|
|
61
|
+
if (/^\s*-\s+/.test(line)) {
|
|
62
|
+
flush();
|
|
63
|
+
const nestedObservationMatch = /^\s*-\s+Observation:\s*(.*?)\s*$/.exec(line);
|
|
64
|
+
if (nestedObservationMatch) {
|
|
65
|
+
currentFields = { observation: nestedObservationMatch[1] ?? "" };
|
|
66
|
+
currentKey = "observation";
|
|
67
|
+
currentLine = index + 1;
|
|
68
|
+
}
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const fieldMatch = /^\s{2,}([A-Za-z][A-Za-z0-9 _-]*):\s*(.*?)\s*$/.exec(line);
|
|
72
|
+
if (fieldMatch) {
|
|
73
|
+
currentKey = normalizeKey(fieldMatch[1] ?? "");
|
|
74
|
+
currentFields[currentKey] = fieldMatch[2] ?? "";
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (currentKey && /^\s{2,}\S/.test(line)) {
|
|
78
|
+
appendFieldValue(currentFields, currentKey, line.trim(), "\n");
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (!line.trim())
|
|
82
|
+
continue;
|
|
83
|
+
if (currentKey)
|
|
84
|
+
appendFieldValue(currentFields, currentKey, line.trim());
|
|
85
|
+
}
|
|
86
|
+
flush();
|
|
87
|
+
return candidates;
|
|
88
|
+
}
|
|
89
|
+
function nextIncidentId(entries, now) {
|
|
90
|
+
const dateStamp = `${now.getUTCFullYear()}${String(now.getUTCMonth() + 1).padStart(2, "0")}${String(now.getUTCDate()).padStart(2, "0")}`;
|
|
91
|
+
const prefix = `INC-${dateStamp}-`;
|
|
92
|
+
let max = 0;
|
|
93
|
+
for (const entry of entries) {
|
|
94
|
+
if (!entry.id.startsWith(prefix))
|
|
95
|
+
continue;
|
|
96
|
+
const num = Number.parseInt(entry.id.slice(prefix.length), 10);
|
|
97
|
+
if (Number.isInteger(num) && num > max)
|
|
98
|
+
max = num;
|
|
99
|
+
}
|
|
100
|
+
return `${prefix}${String(max + 1).padStart(2, "0")}`;
|
|
101
|
+
}
|
|
102
|
+
function buildPromotionIssues(candidate) {
|
|
103
|
+
const missingFields = [];
|
|
104
|
+
if (!candidate.incidentExternal && !candidate.incidentInternal && candidate.fixability === null) {
|
|
105
|
+
missingFields.push("Fixability: external or IncidentExternal: true");
|
|
106
|
+
}
|
|
107
|
+
if (!candidate.incidentAdvice && !candidate.resolution) {
|
|
108
|
+
missingFields.push("Resolution or IncidentAdvice");
|
|
109
|
+
}
|
|
110
|
+
return missingFields.length > 0 ? { candidate, missingFields } : null;
|
|
111
|
+
}
|
|
112
|
+
function buildIncidentRegistryEntry(opts) {
|
|
113
|
+
const date = opts.now.toISOString().slice(0, 10);
|
|
114
|
+
const scope = opts.candidate.incidentScope ?? summarizeTaskScope(opts.task.scope, opts.task.title);
|
|
115
|
+
const tags = dedupeCaseInsensitive([
|
|
116
|
+
...opts.candidate.incidentTags,
|
|
117
|
+
...opts.task.tags.map((tag) => tag.trim()),
|
|
118
|
+
]);
|
|
119
|
+
const advice = opts.candidate.incidentAdvice ?? opts.candidate.resolution ?? opts.candidate.observation;
|
|
120
|
+
const rule = opts.candidate.incidentRule ?? buildDerivedIncidentRule(scope);
|
|
121
|
+
const state = resolveIncidentState({
|
|
122
|
+
registry: opts.registry,
|
|
123
|
+
entry: {
|
|
124
|
+
scope,
|
|
125
|
+
failure: opts.candidate.observation,
|
|
126
|
+
rule,
|
|
127
|
+
},
|
|
128
|
+
now: opts.now,
|
|
129
|
+
});
|
|
130
|
+
const match = buildMatchTerms({
|
|
131
|
+
scope,
|
|
132
|
+
tags,
|
|
133
|
+
explicitMatch: opts.candidate.incidentMatch,
|
|
134
|
+
extraText: [opts.task.title, opts.task.description, advice],
|
|
135
|
+
});
|
|
136
|
+
return {
|
|
137
|
+
id: nextIncidentId(opts.registry.entries, opts.now),
|
|
138
|
+
date,
|
|
139
|
+
scope,
|
|
140
|
+
failure: opts.candidate.observation,
|
|
141
|
+
rule,
|
|
142
|
+
evidence: `task ${opts.task.id}${opts.task.commitHash ? `; commit ${opts.task.commitHash.slice(0, 12)}` : ""}`,
|
|
143
|
+
enforcement: "manual",
|
|
144
|
+
state,
|
|
145
|
+
tags,
|
|
146
|
+
match,
|
|
147
|
+
advice,
|
|
148
|
+
sourceTask: opts.task.id,
|
|
149
|
+
fixability: opts.candidate.fixability ?? (opts.candidate.incidentInternal ? "repo-fixable" : "external"),
|
|
150
|
+
rawFields: {},
|
|
151
|
+
line: 0,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
export function planIncidentCollection(opts) {
|
|
155
|
+
const parsed = parseIncidentFindingBlocks(opts.findings);
|
|
156
|
+
const candidates = parsed
|
|
157
|
+
.filter((candidate) => candidate.shouldPromote)
|
|
158
|
+
.map(({ shouldPromote: _shouldPromote, ...candidate }) => candidate);
|
|
159
|
+
const skipped = parsed
|
|
160
|
+
.filter((candidate) => !candidate.shouldPromote)
|
|
161
|
+
.map(({ observation, line, rawFields }) => ({
|
|
162
|
+
observation,
|
|
163
|
+
line,
|
|
164
|
+
reason: "not_marked_external_or_promotable",
|
|
165
|
+
rawFields,
|
|
166
|
+
}));
|
|
167
|
+
const issues = [];
|
|
168
|
+
const promotable = [];
|
|
169
|
+
const duplicates = [];
|
|
170
|
+
const now = opts.now ?? new Date();
|
|
171
|
+
const seenFingerprints = new Set(opts.registry.entries.map((entry) => buildIncidentFingerprint(entry)));
|
|
172
|
+
for (const candidate of candidates) {
|
|
173
|
+
const issue = buildPromotionIssues(candidate);
|
|
174
|
+
if (issue) {
|
|
175
|
+
issues.push(issue);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
const entry = buildIncidentRegistryEntry({
|
|
179
|
+
task: opts.task,
|
|
180
|
+
candidate,
|
|
181
|
+
now,
|
|
182
|
+
registry: parseIncidentRegistry(appendIncidentRegistryEntries(createIncidentRegistrySkeleton(), [
|
|
183
|
+
...opts.registry.entries,
|
|
184
|
+
...promotable.map((item) => item.entry),
|
|
185
|
+
])),
|
|
186
|
+
});
|
|
187
|
+
const fingerprint = buildIncidentFingerprint(entry);
|
|
188
|
+
const draft = { candidate, entry, fingerprint };
|
|
189
|
+
if (seenFingerprints.has(fingerprint)) {
|
|
190
|
+
duplicates.push(draft);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
seenFingerprints.add(fingerprint);
|
|
194
|
+
promotable.push(draft);
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
candidates,
|
|
198
|
+
skipped,
|
|
199
|
+
promotable,
|
|
200
|
+
duplicates,
|
|
201
|
+
issues,
|
|
202
|
+
findingsTextPresent: opts.findings.trim().length > 0,
|
|
203
|
+
structuredFindingCount: parsed.length,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IncidentRegistry, IncidentRegistryEntry } from "./types.js";
|
|
2
|
+
export declare function createIncidentRegistrySkeleton(): string;
|
|
3
|
+
export declare function parseIncidentRegistry(text: string): IncidentRegistry;
|
|
4
|
+
export declare function formatIncidentRegistryEntry(entry: IncidentRegistryEntry): string;
|
|
5
|
+
export declare function appendIncidentRegistryEntries(currentText: string, entries: readonly IncidentRegistryEntry[]): string;
|
|
6
|
+
//# sourceMappingURL=registry-strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-strategy.d.ts","sourceRoot":"","sources":["../../../src/runtime/incidents/registry-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAe1E,wBAAgB,8BAA8B,IAAI,MAAM,CAkCvD;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAkHpE;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM,CAEhF;AAiJD,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,SAAS,qBAAqB,EAAE,GACxC,MAAM,CAOR"}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { appendFieldValue, buildIncidentFingerprint, COMPACT_INCIDENTS_HEADER, deriveSourceTask, incidentField, normalizeKey, normalizeLines, parseCsvList, parseEntryState, parseFixability, STRUCTURED_INCIDENTS_HEADER, } from "./shared.js";
|
|
2
|
+
export function createIncidentRegistrySkeleton() {
|
|
3
|
+
return [
|
|
4
|
+
STRUCTURED_INCIDENTS_HEADER,
|
|
5
|
+
"",
|
|
6
|
+
"## Entry contract",
|
|
7
|
+
"",
|
|
8
|
+
"- Add entries append-only.",
|
|
9
|
+
"- Every entry MUST include: `id`, `date`, `scope`, `failure`, `rule`, `evidence`, `enforcement`, `state`.",
|
|
10
|
+
"- New machine-matched entries SHOULD also include: `tags`, `match`, `advice`, `source_task`, `fixability`.",
|
|
11
|
+
"- `rule` MUST be concrete and testable (`MUST` / `MUST NOT`).",
|
|
12
|
+
"- `fixability: external` means the issue cannot be removed by changing only repository code and should stay as reusable operational advice.",
|
|
13
|
+
"- `fixability: repo-fixable` means the issue can be removed by repository code changes and should still be captured as reusable incident advice when explicitly marked.",
|
|
14
|
+
"- First auto-promoted reusable incidents normally enter as `open` and still participate in targeted advice lookup; recurring equivalent incidents can append later `stabilized` entries.",
|
|
15
|
+
"- `state` values: `open`, `stabilized`, `promoted`.",
|
|
16
|
+
"",
|
|
17
|
+
"## Entry template",
|
|
18
|
+
"",
|
|
19
|
+
"- id: `INC-YYYYMMDD-NN`",
|
|
20
|
+
"- date: `YYYY-MM-DD`",
|
|
21
|
+
"- scope: `<affected scope>`",
|
|
22
|
+
"- tags: `<comma-separated matching tags>`",
|
|
23
|
+
"- match: `<comma-separated lookup keywords>`",
|
|
24
|
+
"- failure: `<observed failure mode>`",
|
|
25
|
+
"- advice: `<reusable recovery or prevention guidance>`",
|
|
26
|
+
"- rule: `<new or refined MUST/MUST NOT>`",
|
|
27
|
+
"- evidence: `<task ids / logs / links>`",
|
|
28
|
+
"- enforcement: `<CI|test|lint|script|manual>`",
|
|
29
|
+
"- source_task: `<task id>`",
|
|
30
|
+
"- fixability: `<external|repo-fixable>`",
|
|
31
|
+
"- state: `<open|stabilized|promoted>`",
|
|
32
|
+
"",
|
|
33
|
+
"## Entries",
|
|
34
|
+
"",
|
|
35
|
+
].join("\n");
|
|
36
|
+
}
|
|
37
|
+
export function parseIncidentRegistry(text) {
|
|
38
|
+
const lines = normalizeLines(text);
|
|
39
|
+
const entries = [];
|
|
40
|
+
let currentFields = null;
|
|
41
|
+
let currentLine = 0;
|
|
42
|
+
let currentKey = null;
|
|
43
|
+
const flush = () => {
|
|
44
|
+
if (!currentFields)
|
|
45
|
+
return;
|
|
46
|
+
const id = currentFields.id?.trim();
|
|
47
|
+
if (!id || !/^INC-\d{8}-\d+$/u.test(id)) {
|
|
48
|
+
currentFields = null;
|
|
49
|
+
currentKey = null;
|
|
50
|
+
currentLine = 0;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const scope = currentFields.scope?.trim() ?? "";
|
|
54
|
+
const failure = currentFields.failure?.trim() ?? "";
|
|
55
|
+
const rule = currentFields.rule?.trim() ?? "";
|
|
56
|
+
const evidence = currentFields.evidence?.trim() ?? "";
|
|
57
|
+
const enforcement = currentFields.enforcement?.trim() ?? "manual";
|
|
58
|
+
if (!scope || !failure || !rule || !evidence) {
|
|
59
|
+
currentFields = null;
|
|
60
|
+
currentKey = null;
|
|
61
|
+
currentLine = 0;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const sourceTask = deriveSourceTask(currentFields.source_task ?? currentFields.sourcetask, evidence);
|
|
65
|
+
entries.push({
|
|
66
|
+
id,
|
|
67
|
+
date: currentFields.date?.trim() ?? "",
|
|
68
|
+
scope,
|
|
69
|
+
tags: parseCsvList(currentFields.tags),
|
|
70
|
+
match: parseCsvList(currentFields.match),
|
|
71
|
+
failure,
|
|
72
|
+
advice: currentFields.advice?.trim() || null,
|
|
73
|
+
rule,
|
|
74
|
+
evidence,
|
|
75
|
+
enforcement,
|
|
76
|
+
sourceTask,
|
|
77
|
+
fixability: parseFixability(currentFields.fixability),
|
|
78
|
+
state: parseEntryState(currentFields.state),
|
|
79
|
+
rawFields: { ...currentFields },
|
|
80
|
+
line: currentLine,
|
|
81
|
+
});
|
|
82
|
+
currentFields = null;
|
|
83
|
+
currentKey = null;
|
|
84
|
+
currentLine = 0;
|
|
85
|
+
};
|
|
86
|
+
for (const [index, line] of lines.entries()) {
|
|
87
|
+
const trimmed = line.trim();
|
|
88
|
+
const inlineFields = parseInlineIncidentEntry(trimmed);
|
|
89
|
+
if (inlineFields) {
|
|
90
|
+
flush();
|
|
91
|
+
currentFields = { ...inlineFields };
|
|
92
|
+
const keys = Object.keys(inlineFields);
|
|
93
|
+
currentKey = keys.at(-1) ?? "id";
|
|
94
|
+
currentLine = index + 1;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const idMatch = /^\s*-\s+id:\s*(.*?)\s*$/u.exec(line);
|
|
98
|
+
if (idMatch) {
|
|
99
|
+
flush();
|
|
100
|
+
currentFields = { id: idMatch[1] ?? "" };
|
|
101
|
+
currentKey = "id";
|
|
102
|
+
currentLine = index + 1;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (!currentFields)
|
|
106
|
+
continue;
|
|
107
|
+
if (/^##\s+/.test(trimmed)) {
|
|
108
|
+
flush();
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (/^\s*-\s+/.test(line)) {
|
|
112
|
+
flush();
|
|
113
|
+
const nestedIdMatch = /^\s*-\s+id:\s*(.*?)\s*$/u.exec(line);
|
|
114
|
+
if (nestedIdMatch) {
|
|
115
|
+
currentFields = { id: nestedIdMatch[1] ?? "" };
|
|
116
|
+
currentKey = "id";
|
|
117
|
+
currentLine = index + 1;
|
|
118
|
+
}
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const fieldMatch = /^\s{2,}([A-Za-z][A-Za-z0-9 _-]*):\s*(.*?)\s*$/u.exec(line);
|
|
122
|
+
if (fieldMatch) {
|
|
123
|
+
currentKey = normalizeKey(fieldMatch[1] ?? "");
|
|
124
|
+
currentFields[currentKey] = fieldMatch[2] ?? "";
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (currentKey && /^\s{2,}\S/.test(line)) {
|
|
128
|
+
appendFieldValue(currentFields, currentKey, line.trim(), "\n");
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (!trimmed) {
|
|
132
|
+
flush();
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (currentKey)
|
|
136
|
+
appendFieldValue(currentFields, currentKey, line.trim());
|
|
137
|
+
}
|
|
138
|
+
flush();
|
|
139
|
+
return { entries };
|
|
140
|
+
}
|
|
141
|
+
export function formatIncidentRegistryEntry(entry) {
|
|
142
|
+
return formatIncidentRegistryEntryForStyle(entry, "structured");
|
|
143
|
+
}
|
|
144
|
+
function parseInlineIncidentEntry(trimmedLine) {
|
|
145
|
+
if (!trimmedLine.startsWith("- "))
|
|
146
|
+
return null;
|
|
147
|
+
const body = trimmedLine.slice(2).trim();
|
|
148
|
+
if (!body)
|
|
149
|
+
return null;
|
|
150
|
+
const segments = body.split(/\s+\|\s+(?=[a-z_]+:\s*)/u);
|
|
151
|
+
const fields = {};
|
|
152
|
+
for (const segment of segments) {
|
|
153
|
+
const match = /^([a-z_]+):\s*(.*?)\s*$/u.exec(segment.trim());
|
|
154
|
+
if (!match)
|
|
155
|
+
return null;
|
|
156
|
+
const key = normalizeKey(match[1] ?? "");
|
|
157
|
+
if (!key)
|
|
158
|
+
return null;
|
|
159
|
+
fields[key] = match[2] ?? "";
|
|
160
|
+
}
|
|
161
|
+
return fields.id ? fields : null;
|
|
162
|
+
}
|
|
163
|
+
function formatIncidentRegistryEntryForStyle(entry, style) {
|
|
164
|
+
const compactFields = [
|
|
165
|
+
incidentField("id", entry.id),
|
|
166
|
+
incidentField("date", entry.date),
|
|
167
|
+
incidentField("scope", entry.scope),
|
|
168
|
+
...(entry.tags.length > 0 ? [incidentField("tags", entry.tags.join(", "))] : []),
|
|
169
|
+
...(entry.match.length > 0 ? [incidentField("match", entry.match.join(", "))] : []),
|
|
170
|
+
incidentField("failure", entry.failure),
|
|
171
|
+
...(entry.advice ? [incidentField("advice", entry.advice)] : []),
|
|
172
|
+
incidentField("rule", entry.rule),
|
|
173
|
+
incidentField("evidence", entry.evidence),
|
|
174
|
+
incidentField("enforcement", entry.enforcement),
|
|
175
|
+
...(entry.fixability ? [incidentField("fixability", entry.fixability)] : []),
|
|
176
|
+
incidentField("state", entry.state),
|
|
177
|
+
];
|
|
178
|
+
if (style === "compact") {
|
|
179
|
+
return `- ${compactFields.map(([key, value]) => `${key}: ${value}`).join(" | ")}`;
|
|
180
|
+
}
|
|
181
|
+
const structuredFields = [
|
|
182
|
+
incidentField("id", entry.id),
|
|
183
|
+
incidentField("date", entry.date),
|
|
184
|
+
incidentField("scope", entry.scope),
|
|
185
|
+
...(entry.tags.length > 0 ? [incidentField("tags", entry.tags.join(", "))] : []),
|
|
186
|
+
...(entry.match.length > 0 ? [incidentField("match", entry.match.join(", "))] : []),
|
|
187
|
+
incidentField("failure", entry.failure),
|
|
188
|
+
...(entry.advice ? [incidentField("advice", entry.advice)] : []),
|
|
189
|
+
incidentField("rule", entry.rule),
|
|
190
|
+
incidentField("evidence", entry.evidence),
|
|
191
|
+
incidentField("enforcement", entry.enforcement),
|
|
192
|
+
...(entry.sourceTask ? [incidentField("source_task", entry.sourceTask)] : []),
|
|
193
|
+
...(entry.fixability ? [incidentField("fixability", entry.fixability)] : []),
|
|
194
|
+
incidentField("state", entry.state),
|
|
195
|
+
];
|
|
196
|
+
return [
|
|
197
|
+
`- ${structuredFields[0]?.[0]}: ${structuredFields[0]?.[1] ?? ""}`,
|
|
198
|
+
...structuredFields.slice(1).map(([key, value]) => ` ${key}: ${value}`),
|
|
199
|
+
].join("\n");
|
|
200
|
+
}
|
|
201
|
+
function detectRegistryStyle(text) {
|
|
202
|
+
return /(^|\n)## Entries\s*$/mu.test(text) || /(^|\n)## Entry contract\s*$/mu.test(text)
|
|
203
|
+
? "structured"
|
|
204
|
+
: "compact";
|
|
205
|
+
}
|
|
206
|
+
function entryRichness(entry) {
|
|
207
|
+
return [
|
|
208
|
+
entry.sourceTask ? 4 : 0,
|
|
209
|
+
entry.advice ? 3 : 0,
|
|
210
|
+
entry.tags.length,
|
|
211
|
+
entry.match.length,
|
|
212
|
+
entry.fixability ? 1 : 0,
|
|
213
|
+
entry.evidence.length > 0 ? 1 : 0,
|
|
214
|
+
].reduce((sum, item) => sum + item, 0);
|
|
215
|
+
}
|
|
216
|
+
function nextIncidentIdForDate(dateStamp, usedIds, nextByDate) {
|
|
217
|
+
let next = nextByDate.get(dateStamp) ?? 0;
|
|
218
|
+
do {
|
|
219
|
+
next += 1;
|
|
220
|
+
} while (usedIds.has(`INC-${dateStamp}-${String(next).padStart(2, "0")}`));
|
|
221
|
+
nextByDate.set(dateStamp, next);
|
|
222
|
+
return `INC-${dateStamp}-${String(next).padStart(2, "0")}`;
|
|
223
|
+
}
|
|
224
|
+
function normalizeIncidentRegistryEntries(entries) {
|
|
225
|
+
const byFingerprint = new Map();
|
|
226
|
+
const orderedFingerprints = [];
|
|
227
|
+
for (const entry of entries) {
|
|
228
|
+
const fingerprint = buildIncidentFingerprint(entry);
|
|
229
|
+
const existing = byFingerprint.get(fingerprint);
|
|
230
|
+
if (!existing) {
|
|
231
|
+
byFingerprint.set(fingerprint, { ...entry });
|
|
232
|
+
orderedFingerprints.push(fingerprint);
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
if (entryRichness(entry) >= entryRichness(existing)) {
|
|
236
|
+
byFingerprint.set(fingerprint, { ...entry });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const normalized = orderedFingerprints.map((fingerprint) => byFingerprint.get(fingerprint));
|
|
240
|
+
const usedIds = new Set();
|
|
241
|
+
const nextByDate = new Map();
|
|
242
|
+
for (const entry of normalized) {
|
|
243
|
+
const match = /^INC-(\d{8})-(\d+)$/u.exec(entry.id);
|
|
244
|
+
if (!match)
|
|
245
|
+
continue;
|
|
246
|
+
const [, dateStamp, seqRaw] = match;
|
|
247
|
+
const seq = Number.parseInt(seqRaw ?? "", 10);
|
|
248
|
+
if (!Number.isInteger(seq))
|
|
249
|
+
continue;
|
|
250
|
+
const existing = nextByDate.get(dateStamp) ?? 0;
|
|
251
|
+
if (seq > existing)
|
|
252
|
+
nextByDate.set(dateStamp, seq);
|
|
253
|
+
}
|
|
254
|
+
return normalized.map((entry) => {
|
|
255
|
+
const dateStamp = /^\d{4}-\d{2}-\d{2}$/u.test(entry.date)
|
|
256
|
+
? entry.date.replaceAll("-", "")
|
|
257
|
+
: "00000000";
|
|
258
|
+
const nextId = usedIds.has(entry.id)
|
|
259
|
+
? nextIncidentIdForDate(dateStamp, usedIds, nextByDate)
|
|
260
|
+
: entry.id;
|
|
261
|
+
usedIds.add(nextId);
|
|
262
|
+
return nextId === entry.id ? entry : { ...entry, id: nextId };
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
function renderIncidentRegistryDocument(entries, style) {
|
|
266
|
+
const header = style === "structured" ? createIncidentRegistrySkeleton().trimEnd() : COMPACT_INCIDENTS_HEADER;
|
|
267
|
+
if (entries.length === 0)
|
|
268
|
+
return `${header}\n`;
|
|
269
|
+
const separator = style === "structured" ? "\n\n" : "\n";
|
|
270
|
+
return `${header}\n${entries.map((entry) => formatIncidentRegistryEntryForStyle(entry, style)).join(separator)}\n`;
|
|
271
|
+
}
|
|
272
|
+
export function appendIncidentRegistryEntries(currentText, entries) {
|
|
273
|
+
if (entries.length === 0)
|
|
274
|
+
return currentText;
|
|
275
|
+
const baseText = currentText.trim().length > 0 ? currentText : createIncidentRegistrySkeleton();
|
|
276
|
+
const style = detectRegistryStyle(baseText);
|
|
277
|
+
const existing = parseIncidentRegistry(baseText);
|
|
278
|
+
const merged = normalizeIncidentRegistryEntries([...existing.entries, ...entries]);
|
|
279
|
+
return renderIncidentRegistryDocument(merged, style);
|
|
280
|
+
}
|
|
@@ -1,26 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export declare function formatIncidentRegistryEntry(entry: IncidentRegistryEntry): string;
|
|
5
|
-
export declare function appendIncidentRegistryEntries(currentText: string, entries: readonly IncidentRegistryEntry[]): string;
|
|
6
|
-
export declare function extractIncidentCandidatesFromFindings(findings: string): IncidentFindingCandidate[];
|
|
7
|
-
export declare function planIncidentCollection(opts: {
|
|
8
|
-
task: IncidentPromotionTaskContext;
|
|
9
|
-
findings: string;
|
|
10
|
-
registry: IncidentRegistry;
|
|
11
|
-
now?: Date;
|
|
12
|
-
}): IncidentCollectionPlan;
|
|
13
|
-
export declare function buildIncidentAdviceQueryFromTask(opts: {
|
|
14
|
-
taskId: string;
|
|
15
|
-
title: string;
|
|
16
|
-
description: string;
|
|
17
|
-
scope?: string | null;
|
|
18
|
-
tags: readonly string[];
|
|
19
|
-
}): IncidentAdviceQuery;
|
|
20
|
-
export declare function resolveIncidentAdviceMatches(opts: {
|
|
21
|
-
query: IncidentAdviceQuery;
|
|
22
|
-
registry: IncidentRegistry;
|
|
23
|
-
limit?: number;
|
|
24
|
-
}): IncidentAdviceMatch[];
|
|
25
|
-
export declare function renderIncidentAdvice(matches: readonly IncidentAdviceMatch[]): string;
|
|
1
|
+
export { appendIncidentRegistryEntries, createIncidentRegistrySkeleton, formatIncidentRegistryEntry, parseIncidentRegistry, } from "./registry-strategy.js";
|
|
2
|
+
export { buildIncidentAdviceQueryFromTask, renderIncidentAdvice, resolveIncidentAdviceMatches, } from "./advice-strategy.js";
|
|
3
|
+
export { extractIncidentCandidatesFromFindings, planIncidentCollection } from "./plan-strategy.js";
|
|
26
4
|
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/runtime/incidents/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/runtime/incidents/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gCAAgC,EAChC,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,qCAAqC,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC"}
|