agentplane 0.3.13 → 0.3.14
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 +278 -178
- 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-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
|
@@ -1,493 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { applyTaskDocMutations, docChanged, extractTaskDoc, mergeTaskDoc, normalizeTaskDocVersion, parseTaskReadme, renderTaskReadme, taskDocToSectionMap, } from "@agentplaneorg/core";
|
|
4
|
-
import { LocalBackend, taskRecordToData, } from "../../backends/task-backend.js";
|
|
5
|
-
import { exitCodeForError } from "../../cli/exit-codes.js";
|
|
6
|
-
import { CliError } from "../../shared/errors.js";
|
|
7
|
-
import { assertExpectedTaskDoc, assertExpectedTaskSection, } from "../../shared/task-doc-conflicts.js";
|
|
8
|
-
import { writeTextIfChanged } from "../../shared/write-if-changed.js";
|
|
9
|
-
import { resolveDocUpdatedBy, taskDataToFrontmatter } from "./task-backend.js";
|
|
10
|
-
export function setTaskFieldsIntent(task) {
|
|
11
|
-
return { kind: "set-task-fields", task };
|
|
12
|
-
}
|
|
13
|
-
export function appendTaskCommentsIntent(comments) {
|
|
14
|
-
return { kind: "append-comments", comments };
|
|
15
|
-
}
|
|
16
|
-
export function appendTaskCommentIntent(comment) {
|
|
17
|
-
return appendTaskCommentsIntent([comment]);
|
|
18
|
-
}
|
|
19
|
-
export function appendTaskEventsIntent(events) {
|
|
20
|
-
return { kind: "append-events", events };
|
|
21
|
-
}
|
|
22
|
-
export function appendTaskEventIntent(event) {
|
|
23
|
-
return appendTaskEventsIntent([event]);
|
|
24
|
-
}
|
|
25
|
-
export function replaceTaskDocIntent(opts) {
|
|
26
|
-
return { kind: "replace-doc", ...opts };
|
|
27
|
-
}
|
|
28
|
-
export function setTaskSectionIntent(opts) {
|
|
29
|
-
return { kind: "set-section", ...opts };
|
|
30
|
-
}
|
|
31
|
-
export function touchTaskDocMetaIntent(opts = {}) {
|
|
32
|
-
return { kind: "touch-doc-meta", ...opts };
|
|
33
|
-
}
|
|
34
|
-
function taskReadmePath(ctx, taskId) {
|
|
35
|
-
return path.join(ctx.resolvedProject.gitRoot, ctx.config.paths.workflow_dir, taskId, "README.md");
|
|
36
|
-
}
|
|
37
|
-
function normalizeTaskRevision(value, fallback = 1) {
|
|
38
|
-
return Number.isInteger(value) && Number(value) > 0 ? Number(value) : fallback;
|
|
39
|
-
}
|
|
40
|
-
function readStoredTaskRevision(value) {
|
|
41
|
-
return Number.isInteger(value) && Number(value) > 0 ? Number(value) : null;
|
|
42
|
-
}
|
|
43
|
-
function normalizeComments(task) {
|
|
44
|
-
return Array.isArray(task.comments)
|
|
45
|
-
? task.comments.filter((item) => !!item && typeof item.author === "string" && typeof item.body === "string")
|
|
46
|
-
: [];
|
|
47
|
-
}
|
|
48
|
-
function normalizeEvents(task) {
|
|
49
|
-
return Array.isArray(task.events)
|
|
50
|
-
? task.events.filter((item) => !!item &&
|
|
51
|
-
typeof item.type === "string" &&
|
|
52
|
-
typeof item.at === "string" &&
|
|
53
|
-
typeof item.author === "string")
|
|
54
|
-
: [];
|
|
55
|
-
}
|
|
56
|
-
function isConcurrentReadmeChangeError(err) {
|
|
57
|
-
return (err instanceof CliError &&
|
|
58
|
-
err.code === "E_IO" &&
|
|
59
|
-
err.message.startsWith("Task README changed concurrently:"));
|
|
60
|
-
}
|
|
61
|
-
function throwTaskRevisionConflict(opts) {
|
|
62
|
-
throw new CliError({
|
|
63
|
-
exitCode: exitCodeForError("E_VALIDATION"),
|
|
64
|
-
code: "E_VALIDATION",
|
|
65
|
-
message: `Task revision changed concurrently: ${opts.taskId} ` +
|
|
66
|
-
`(expected revision ${opts.expectedRevision}, current revision ${opts.currentRevision})`,
|
|
67
|
-
context: {
|
|
68
|
-
task_id: opts.taskId,
|
|
69
|
-
expected_revision: opts.expectedRevision,
|
|
70
|
-
current_revision: opts.currentRevision,
|
|
71
|
-
reason_code: "task_revision_conflict",
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
function applyDocMutationsToState(docState, mutations, opts) {
|
|
76
|
-
const applied = applyTaskDocMutations(docState, mutations, {
|
|
77
|
-
now: opts.docUpdatedAt,
|
|
78
|
-
});
|
|
79
|
-
return {
|
|
80
|
-
...docState,
|
|
81
|
-
doc: applied.doc,
|
|
82
|
-
sections: applied.sections,
|
|
83
|
-
doc_version: applied.doc_version,
|
|
84
|
-
doc_updated_at: applied.doc_updated_at,
|
|
85
|
-
doc_updated_by: applied.doc_updated_by,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function normalizeTaskStoreIntents(intents) {
|
|
89
|
-
if (!intents)
|
|
90
|
-
return [];
|
|
91
|
-
if (Array.isArray(intents)) {
|
|
92
|
-
return intents.filter((intent) => intent != null);
|
|
93
|
-
}
|
|
94
|
-
return [intents];
|
|
95
|
-
}
|
|
96
|
-
function patchToIntents(patch) {
|
|
97
|
-
if (!patch)
|
|
98
|
-
return [];
|
|
99
|
-
const intents = [];
|
|
100
|
-
if (patch.task) {
|
|
101
|
-
intents.push(setTaskFieldsIntent(patch.task));
|
|
102
|
-
}
|
|
103
|
-
if (patch.appendComments && patch.appendComments.length > 0) {
|
|
104
|
-
intents.push(appendTaskCommentsIntent(patch.appendComments));
|
|
105
|
-
}
|
|
106
|
-
if (patch.appendEvents && patch.appendEvents.length > 0) {
|
|
107
|
-
intents.push(appendTaskEventsIntent(patch.appendEvents));
|
|
108
|
-
}
|
|
109
|
-
if (patch.doc) {
|
|
110
|
-
intents.push(patch.doc.kind === "replace-doc"
|
|
111
|
-
? replaceTaskDocIntent({
|
|
112
|
-
doc: patch.doc.doc,
|
|
113
|
-
expectedCurrentDoc: patch.doc.expectedCurrentDoc,
|
|
114
|
-
})
|
|
115
|
-
: setTaskSectionIntent({
|
|
116
|
-
section: patch.doc.section,
|
|
117
|
-
text: patch.doc.text,
|
|
118
|
-
requiredSections: patch.doc.requiredSections,
|
|
119
|
-
expectedCurrentText: patch.doc.expectedCurrentText,
|
|
120
|
-
}));
|
|
121
|
-
}
|
|
122
|
-
if (patch.docMeta && (patch.doc !== undefined || patch.docMeta.touch === true)) {
|
|
123
|
-
intents.push(touchTaskDocMetaIntent({
|
|
124
|
-
updatedBy: patch.docMeta.updatedBy,
|
|
125
|
-
version: patch.docMeta.version,
|
|
126
|
-
}));
|
|
127
|
-
}
|
|
128
|
-
return intents;
|
|
129
|
-
}
|
|
130
|
-
export function taskStorePatchFromIntents(intents) {
|
|
131
|
-
const normalized = normalizeTaskStoreIntents(intents);
|
|
132
|
-
if (normalized.length === 0)
|
|
133
|
-
return null;
|
|
134
|
-
const patch = {};
|
|
135
|
-
for (const intent of normalized) {
|
|
136
|
-
switch (intent.kind) {
|
|
137
|
-
case "set-task-fields": {
|
|
138
|
-
patch.task = patch.task ? { ...patch.task, ...intent.task } : { ...intent.task };
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
case "append-comments": {
|
|
142
|
-
if (intent.comments.length > 0) {
|
|
143
|
-
patch.appendComments = [...(patch.appendComments ?? []), ...intent.comments];
|
|
144
|
-
}
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
case "append-events": {
|
|
148
|
-
if (intent.events.length > 0) {
|
|
149
|
-
patch.appendEvents = [...(patch.appendEvents ?? []), ...intent.events];
|
|
150
|
-
}
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
case "replace-doc": {
|
|
154
|
-
const docPatch = {
|
|
155
|
-
kind: "replace-doc",
|
|
156
|
-
doc: intent.doc,
|
|
157
|
-
};
|
|
158
|
-
if (intent.expectedCurrentDoc === undefined) {
|
|
159
|
-
patch.doc = docPatch;
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
docPatch.expectedCurrentDoc = intent.expectedCurrentDoc;
|
|
163
|
-
patch.doc = docPatch;
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
case "set-section": {
|
|
167
|
-
const sectionPatch = {
|
|
168
|
-
kind: "set-section",
|
|
169
|
-
section: intent.section,
|
|
170
|
-
text: intent.text,
|
|
171
|
-
requiredSections: [...intent.requiredSections],
|
|
172
|
-
};
|
|
173
|
-
if (intent.expectedCurrentText === undefined) {
|
|
174
|
-
patch.doc = sectionPatch;
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
sectionPatch.expectedCurrentText = intent.expectedCurrentText;
|
|
178
|
-
patch.doc = sectionPatch;
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
case "touch-doc-meta": {
|
|
182
|
-
patch.docMeta = {
|
|
183
|
-
touch: true,
|
|
184
|
-
updatedBy: intent.updatedBy ?? patch.docMeta?.updatedBy,
|
|
185
|
-
version: intent.version ?? patch.docMeta?.version,
|
|
186
|
-
};
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return patch;
|
|
192
|
-
}
|
|
193
|
-
export async function mutateTaskStore(store, taskId, builder, opts = {}) {
|
|
194
|
-
if (typeof store.mutate === "function") {
|
|
195
|
-
return await store.mutate(taskId, builder, opts);
|
|
196
|
-
}
|
|
197
|
-
return await store.patch(taskId, async (current) => taskStorePatchFromIntents(await builder(current)), opts);
|
|
198
|
-
}
|
|
199
|
-
export function applyTaskStoreIntentsToTask(task, intents, opts = {}) {
|
|
200
|
-
const normalizedIntents = normalizeTaskStoreIntents(intents);
|
|
201
|
-
if (normalizedIntents.length === 0)
|
|
202
|
-
return { ...task };
|
|
203
|
-
const current = task;
|
|
204
|
-
const next = { ...current };
|
|
205
|
-
let docState = {
|
|
206
|
-
comments: next.comments ?? null,
|
|
207
|
-
doc: String(next.doc ?? ""),
|
|
208
|
-
doc_updated_by: next.doc_updated_by,
|
|
209
|
-
doc_version: normalizeTaskDocVersion(opts.currentDocVersion ?? task.doc_version),
|
|
210
|
-
owner: next.owner,
|
|
211
|
-
sections: next.sections ?? null,
|
|
212
|
-
};
|
|
213
|
-
let touchDoc = false;
|
|
214
|
-
for (const intent of normalizedIntents) {
|
|
215
|
-
switch (intent.kind) {
|
|
216
|
-
case "set-task-fields": {
|
|
217
|
-
Object.assign(next, intent.task);
|
|
218
|
-
docState = {
|
|
219
|
-
...docState,
|
|
220
|
-
doc_updated_by: next.doc_updated_by,
|
|
221
|
-
doc_version: normalizeTaskDocVersion(next.doc_version ?? docState.doc_version),
|
|
222
|
-
owner: next.owner,
|
|
223
|
-
};
|
|
224
|
-
break;
|
|
225
|
-
}
|
|
226
|
-
case "append-comments": {
|
|
227
|
-
if (intent.comments.length > 0) {
|
|
228
|
-
next.comments = [...normalizeComments(next), ...intent.comments];
|
|
229
|
-
docState = { ...docState, comments: next.comments };
|
|
230
|
-
}
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
case "append-events": {
|
|
234
|
-
if (intent.events.length > 0) {
|
|
235
|
-
next.events = [...normalizeEvents(next), ...intent.events];
|
|
236
|
-
}
|
|
237
|
-
break;
|
|
238
|
-
}
|
|
239
|
-
case "replace-doc": {
|
|
240
|
-
if (intent.expectedCurrentDoc !== undefined) {
|
|
241
|
-
assertExpectedTaskDoc({
|
|
242
|
-
taskId: current.id,
|
|
243
|
-
currentDoc: docState.doc,
|
|
244
|
-
expectedDoc: intent.expectedCurrentDoc,
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
docState = applyDocMutationsToState(docState, [{ kind: "replace-doc", doc: intent.doc }], {
|
|
248
|
-
docUpdatedAt: opts.docUpdatedAt,
|
|
249
|
-
});
|
|
250
|
-
touchDoc = true;
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
case "set-section": {
|
|
254
|
-
if (intent.expectedCurrentText !== undefined) {
|
|
255
|
-
assertExpectedTaskSection({
|
|
256
|
-
taskId: current.id,
|
|
257
|
-
currentDoc: docState.doc,
|
|
258
|
-
section: intent.section,
|
|
259
|
-
expectedText: intent.expectedCurrentText,
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
docState = applyDocMutationsToState(docState, [
|
|
263
|
-
{
|
|
264
|
-
kind: "set-section",
|
|
265
|
-
section: intent.section,
|
|
266
|
-
text: intent.text,
|
|
267
|
-
requiredSections: intent.requiredSections,
|
|
268
|
-
},
|
|
269
|
-
], { docUpdatedAt: opts.docUpdatedAt });
|
|
270
|
-
touchDoc = true;
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
case "touch-doc-meta": {
|
|
274
|
-
docState = applyDocMutationsToState(docState, [
|
|
275
|
-
{
|
|
276
|
-
kind: "touch-doc-meta",
|
|
277
|
-
updatedBy: intent.updatedBy,
|
|
278
|
-
version: intent.version,
|
|
279
|
-
},
|
|
280
|
-
], { docUpdatedAt: opts.docUpdatedAt });
|
|
281
|
-
touchDoc = true;
|
|
282
|
-
break;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
if (touchDoc) {
|
|
287
|
-
next.doc = docState.doc;
|
|
288
|
-
next.sections = docState.sections ?? taskDocToSectionMap(docState.doc);
|
|
289
|
-
next.doc_version = docState.doc_version;
|
|
290
|
-
next.doc_updated_at = docState.doc_updated_at;
|
|
291
|
-
next.doc_updated_by = docState.doc_updated_by;
|
|
292
|
-
}
|
|
293
|
-
return next;
|
|
294
|
-
}
|
|
295
|
-
function applyTaskStoreIntents(entry, intents) {
|
|
296
|
-
return applyTaskStoreIntentsToTask(entry.task, intents, {
|
|
297
|
-
currentDocVersion: normalizeTaskDocVersion(entry.parsed.frontmatter.doc_version),
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
async function readTaskReadmeCached(opts) {
|
|
301
|
-
const readmePath = taskReadmePath(opts.ctx, opts.taskId);
|
|
302
|
-
let text;
|
|
303
|
-
let st;
|
|
304
|
-
try {
|
|
305
|
-
st = await stat(readmePath);
|
|
306
|
-
text = await readFile(readmePath, "utf8");
|
|
307
|
-
}
|
|
308
|
-
catch (err) {
|
|
309
|
-
const code = err?.code;
|
|
310
|
-
if (code === "ENOENT") {
|
|
311
|
-
throw new CliError({
|
|
312
|
-
exitCode: 4,
|
|
313
|
-
code: "E_IO",
|
|
314
|
-
message: `ENOENT: no such file or directory, open '${readmePath}'`,
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
throw err;
|
|
318
|
-
}
|
|
319
|
-
const parsed = parseTaskReadme(text);
|
|
320
|
-
const task = taskRecordToData({
|
|
321
|
-
id: opts.taskId,
|
|
322
|
-
frontmatter: parsed.frontmatter,
|
|
323
|
-
body: parsed.body,
|
|
324
|
-
readmePath,
|
|
325
|
-
});
|
|
326
|
-
return { task, readmePath, mtimeMs: st.mtimeMs, parsed, rawText: text };
|
|
327
|
-
}
|
|
328
|
-
async function ensureUnchangedOnDisk(opts) {
|
|
329
|
-
const st = await stat(opts.readmePath);
|
|
330
|
-
if (st.mtimeMs !== opts.expectedMtimeMs) {
|
|
331
|
-
throw new CliError({
|
|
332
|
-
exitCode: exitCodeForError("E_IO"),
|
|
333
|
-
code: "E_IO",
|
|
334
|
-
message: `Task README changed concurrently: ${opts.readmePath}`,
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
async function didReadmeChangeOnDisk(opts) {
|
|
339
|
-
try {
|
|
340
|
-
const st = await stat(opts.readmePath);
|
|
341
|
-
return st.mtimeMs !== opts.expectedMtimeMs;
|
|
342
|
-
}
|
|
343
|
-
catch (err) {
|
|
344
|
-
const code = err?.code;
|
|
345
|
-
if (code === "ENOENT")
|
|
346
|
-
return true;
|
|
347
|
-
throw err;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
export class TaskStore {
|
|
351
|
-
ctx;
|
|
352
|
-
cache = new Map();
|
|
353
|
-
constructor(ctx) {
|
|
354
|
-
this.ctx = ctx;
|
|
355
|
-
}
|
|
356
|
-
async get(taskId) {
|
|
357
|
-
const entry = await this.getCached(taskId);
|
|
358
|
-
return entry.task;
|
|
359
|
-
}
|
|
360
|
-
async getCached(taskId) {
|
|
361
|
-
const key = taskId.trim();
|
|
362
|
-
if (!key) {
|
|
363
|
-
throw new CliError({
|
|
364
|
-
exitCode: exitCodeForError("E_USAGE"),
|
|
365
|
-
code: "E_USAGE",
|
|
366
|
-
message: "task id is required",
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
const existing = this.cache.get(key);
|
|
370
|
-
if (existing)
|
|
371
|
-
return await existing;
|
|
372
|
-
const load = (async () => {
|
|
373
|
-
// For now, TaskStore does file-based caching. Non-file backends can still rely on
|
|
374
|
-
// backend.getTask/writeTask elsewhere, but lifecycle/status commands in this repo
|
|
375
|
-
// operate on the local task README files.
|
|
376
|
-
return await readTaskReadmeCached({ ctx: this.ctx, taskId: key });
|
|
377
|
-
})();
|
|
378
|
-
this.cache.set(key, load);
|
|
379
|
-
return await load;
|
|
380
|
-
}
|
|
381
|
-
async update(taskId, updater, opts = {}) {
|
|
382
|
-
return await this.runWithRetry(taskId, opts, async (entry) => {
|
|
383
|
-
return await updater({ ...entry.task });
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
async patch(taskId, builder, opts = {}) {
|
|
387
|
-
return await this.mutate(taskId, async (current) => patchToIntents(await builder(current)), opts);
|
|
388
|
-
}
|
|
389
|
-
async mutate(taskId, builder, opts = {}) {
|
|
390
|
-
return await this.runWithRetry(taskId, opts, async (entry) => {
|
|
391
|
-
const intents = normalizeTaskStoreIntents(await builder({ ...entry.task }));
|
|
392
|
-
return applyTaskStoreIntents(entry, intents);
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
async runWithRetry(taskId, opts, computeNext) {
|
|
396
|
-
for (let attempt = 0; attempt < 2; attempt++) {
|
|
397
|
-
const entry = await this.getCached(taskId);
|
|
398
|
-
if (opts.expectedRevision !== undefined) {
|
|
399
|
-
const expectedRevision = normalizeTaskRevision(opts.expectedRevision);
|
|
400
|
-
const currentRevision = normalizeTaskRevision(entry.task.revision);
|
|
401
|
-
if (currentRevision !== expectedRevision) {
|
|
402
|
-
throwTaskRevisionConflict({ taskId, expectedRevision, currentRevision });
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
let next;
|
|
406
|
-
try {
|
|
407
|
-
next = await computeNext(entry);
|
|
408
|
-
}
|
|
409
|
-
catch (err) {
|
|
410
|
-
if (attempt === 0 &&
|
|
411
|
-
err instanceof CliError &&
|
|
412
|
-
err.code === "E_VALIDATION" &&
|
|
413
|
-
(await didReadmeChangeOnDisk({
|
|
414
|
-
readmePath: entry.readmePath,
|
|
415
|
-
expectedMtimeMs: entry.mtimeMs,
|
|
416
|
-
}))) {
|
|
417
|
-
this.cache.delete(taskId);
|
|
418
|
-
continue;
|
|
419
|
-
}
|
|
420
|
-
throw err;
|
|
421
|
-
}
|
|
422
|
-
try {
|
|
423
|
-
return await this.writeNextTask(taskId, entry, next);
|
|
424
|
-
}
|
|
425
|
-
catch (err) {
|
|
426
|
-
if (attempt === 0 && isConcurrentReadmeChangeError(err)) {
|
|
427
|
-
// Refresh cache and retry once.
|
|
428
|
-
this.cache.delete(taskId);
|
|
429
|
-
continue;
|
|
430
|
-
}
|
|
431
|
-
throw err;
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
// Unreachable, but keeps TS happy.
|
|
435
|
-
const task = await this.get(taskId);
|
|
436
|
-
return { changed: false, task };
|
|
437
|
-
}
|
|
438
|
-
async writeNextTask(taskId, entry, next) {
|
|
439
|
-
// Start from existing frontmatter to preserve any unknown keys.
|
|
440
|
-
const frontmatter = { ...entry.parsed.frontmatter, ...taskDataToFrontmatter(next) };
|
|
441
|
-
let body = entry.parsed.body ?? "";
|
|
442
|
-
const existingDoc = extractTaskDoc(body);
|
|
443
|
-
const now = new Date().toISOString();
|
|
444
|
-
const currentDocVersion = normalizeTaskDocVersion(entry.parsed.frontmatter.doc_version);
|
|
445
|
-
const requestedDocVersion = normalizeTaskDocVersion(next.doc_version, currentDocVersion);
|
|
446
|
-
if (next.doc !== undefined) {
|
|
447
|
-
const nextDoc = String(next.doc ?? "");
|
|
448
|
-
body = mergeTaskDoc(body, nextDoc);
|
|
449
|
-
if (docChanged(existingDoc, nextDoc) || !frontmatter.doc_updated_at) {
|
|
450
|
-
frontmatter.doc_version = requestedDocVersion;
|
|
451
|
-
frontmatter.doc_updated_at = now;
|
|
452
|
-
frontmatter.doc_updated_by = resolveDocUpdatedBy(next);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
frontmatter.doc_version = normalizeTaskDocVersion(frontmatter.doc_version, requestedDocVersion);
|
|
456
|
-
if (typeof frontmatter.doc_updated_at !== "string" ||
|
|
457
|
-
frontmatter.doc_updated_at.trim() === "") {
|
|
458
|
-
frontmatter.doc_updated_at = now;
|
|
459
|
-
}
|
|
460
|
-
if (typeof frontmatter.doc_updated_by !== "string" ||
|
|
461
|
-
frontmatter.doc_updated_by.trim() === "") {
|
|
462
|
-
frontmatter.doc_updated_by = resolveDocUpdatedBy(next);
|
|
463
|
-
}
|
|
464
|
-
const storedRevision = readStoredTaskRevision(entry.parsed.frontmatter.revision);
|
|
465
|
-
frontmatter.revision = storedRevision ?? 1;
|
|
466
|
-
let nextText = renderTaskReadme(frontmatter, body);
|
|
467
|
-
nextText = nextText.endsWith("\n") ? nextText : `${nextText}\n`;
|
|
468
|
-
if (storedRevision !== null && nextText !== entry.rawText) {
|
|
469
|
-
frontmatter.revision = storedRevision + 1;
|
|
470
|
-
nextText = renderTaskReadme(frontmatter, body);
|
|
471
|
-
nextText = nextText.endsWith("\n") ? nextText : `${nextText}\n`;
|
|
472
|
-
}
|
|
473
|
-
await ensureUnchangedOnDisk({
|
|
474
|
-
readmePath: entry.readmePath,
|
|
475
|
-
expectedMtimeMs: entry.mtimeMs,
|
|
476
|
-
});
|
|
477
|
-
const changed = await writeTextIfChanged(entry.readmePath, nextText);
|
|
478
|
-
// Refresh cache with latest content on disk.
|
|
479
|
-
this.cache.set(taskId, (async () => {
|
|
480
|
-
return await readTaskReadmeCached({ ctx: this.ctx, taskId });
|
|
481
|
-
})());
|
|
482
|
-
const updated = await this.get(taskId);
|
|
483
|
-
return { changed, task: updated };
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
export function getTaskStore(ctx) {
|
|
487
|
-
const memo = ctx.memo;
|
|
488
|
-
memo.taskStore ??= new TaskStore(ctx);
|
|
489
|
-
return memo.taskStore;
|
|
490
|
-
}
|
|
491
|
-
export function backendIsLocalFileBackend(ctx) {
|
|
492
|
-
return ctx.taskBackend instanceof LocalBackend;
|
|
493
|
-
}
|
|
1
|
+
export { appendTaskCommentIntent, appendTaskCommentsIntent, appendTaskEventIntent, appendTaskEventsIntent, applyTaskStoreIntentsToTask, mutateTaskStore, replaceTaskDocIntent, setTaskFieldsIntent, setTaskSectionIntent, taskStorePatchFromIntents, touchTaskDocMetaIntent, } from "./task-store/intents.js";
|
|
2
|
+
export { TaskStore, backendIsLocalFileBackend, getTaskStore } from "./task-store/store.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/commands/task/block.ts"],"names":[],"mappings":"AAKA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/commands/task/block.ts"],"names":[],"mappings":"AAKA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAapF,wBAAsB,QAAQ,CAAC,IAAI,EAAE;IACnC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoFlB"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { mapBackendError } from "../../cli/error-map.js";
|
|
2
|
-
import {
|
|
2
|
+
import { createCliEmitter, emitCommandResult } from "../../cli/output.js";
|
|
3
3
|
import { CliError } from "../../shared/errors.js";
|
|
4
4
|
import { ensureActionApproved } from "../shared/approval-requirements.js";
|
|
5
5
|
import { loadCommandContext } from "../shared/task-backend.js";
|
|
6
6
|
import { applyTaskStatusTransitionCommand, defaultCommitEmojiForStatus, nowIso, prepareTaskTransitionComment, requireStructuredComment, runTaskTransitionCommentCommit, } from "./shared.js";
|
|
7
|
+
const output = createCliEmitter();
|
|
7
8
|
export async function cmdBlock(opts) {
|
|
8
9
|
try {
|
|
9
10
|
const ctx = opts.ctx ??
|
|
@@ -71,7 +72,11 @@ export async function cmdBlock(opts) {
|
|
|
71
72
|
}
|
|
72
73
|
if (!opts.quiet) {
|
|
73
74
|
const suffix = commitInfo ? ` (commit=${commitInfo.hash.slice(0, 12)})` : "";
|
|
74
|
-
|
|
75
|
+
emitCommandResult(output, {
|
|
76
|
+
kind: "success",
|
|
77
|
+
action: "blocked",
|
|
78
|
+
target: `${opts.taskId}${suffix}`,
|
|
79
|
+
});
|
|
75
80
|
}
|
|
76
81
|
return 0;
|
|
77
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment.d.ts","sourceRoot":"","sources":["../../../src/commands/task/comment.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"comment.d.ts","sourceRoot":"","sources":["../../../src/commands/task/comment.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAuDpF,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,MAAM,CAAC,CA0BlB"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { mapBackendError } from "../../cli/error-map.js";
|
|
2
|
-
import {
|
|
2
|
+
import { createCliEmitter, emitCommandResult } from "../../cli/output.js";
|
|
3
3
|
import { loadCommandContext } from "../shared/task-backend.js";
|
|
4
4
|
import { applyTaskMutation } from "../shared/task-mutation.js";
|
|
5
5
|
import { appendTaskCommentIntent, appendTaskEventIntent, touchTaskDocMetaIntent, } from "../shared/task-store.js";
|
|
6
6
|
import { appendTaskEvent, normalizeTaskDocVersion, nowIso } from "./shared.js";
|
|
7
|
+
const output = createCliEmitter();
|
|
7
8
|
function buildCommentMutation(opts) {
|
|
8
9
|
return {
|
|
9
10
|
intents: [
|
|
@@ -54,7 +55,11 @@ export async function cmdTaskComment(opts) {
|
|
|
54
55
|
body: opts.body,
|
|
55
56
|
}),
|
|
56
57
|
});
|
|
57
|
-
|
|
58
|
+
emitCommandResult(output, {
|
|
59
|
+
kind: "success",
|
|
60
|
+
action: "commented",
|
|
61
|
+
target: opts.taskId,
|
|
62
|
+
});
|
|
58
63
|
return 0;
|
|
59
64
|
}
|
|
60
65
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finish-shared.d.ts","sourceRoot":"","sources":["../../../src/commands/task/finish-shared.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAG/D,OAAO,
|
|
1
|
+
{"version":3,"file":"finish-shared.d.ts","sourceRoot":"","sources":["../../../src/commands/task/finish-shared.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAG/D,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,YAAY,EAAmB,MAAM,yBAAyB,CAAC;AAWxE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AA0CF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,GAAG,kBAAkB,GAAG,IAAI,CAK5E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,IAAI,CAyCP;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,GAAG,EAAE,cAAc,CAAC;IACpB,KAAK,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,GAAG,IAAI,CAAC;IAC9C,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,2BAA2B,EAAE,OAAO,CAAC;CACtC,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,gBAAgB,CAAC;IACzB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC,CAuDD;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,GAAG,EAAE,cAAc,CAAC;IACpB,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAC3C,GAAG,OAAO,CAAC,IAAI,CAAC,CAuEhB;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,GAAG,EAAE,cAAc,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBhB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ensureDocSections } from "@agentplaneorg/core";
|
|
2
2
|
import { CliError } from "../../shared/errors.js";
|
|
3
3
|
import { cmdCommit } from "../guard/index.js";
|
|
4
|
-
import { loadTaskFromContext } from "../shared/task-backend.js";
|
|
5
|
-
import {
|
|
4
|
+
import { backendUsesLocalTaskStore, loadTaskFromContext, } from "../shared/task-backend.js";
|
|
5
|
+
import { getTaskStore, mutateTaskStore } from "../shared/task-store.js";
|
|
6
6
|
import { ensureAgentFilledRequiredDocSections, executeTaskStatusTransitionRequest, ensureVerificationSatisfiedIfRequired, nowIso, resolvePrimaryTag, toStringArray, } from "./shared.js";
|
|
7
7
|
function normalizeCommentBody(value) {
|
|
8
8
|
return typeof value === "string" ? value.trim() : "";
|
|
@@ -144,7 +144,7 @@ export async function loadTaskForFinish(opts) {
|
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
export async function writeFinishedTasks(opts) {
|
|
147
|
-
const useStore =
|
|
147
|
+
const useStore = backendUsesLocalTaskStore(opts.ctx);
|
|
148
148
|
const store = useStore ? getTaskStore(opts.ctx) : null;
|
|
149
149
|
const taskCount = opts.loadedTasks.length;
|
|
150
150
|
for (const loaded of opts.loadedTasks) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finish.d.ts","sourceRoot":"","sources":["../../../src/commands/task/finish.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"finish.d.ts","sourceRoot":"","sources":["../../../src/commands/task/finish.ts"],"names":[],"mappings":"AAaA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AAuMnC,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,iBAAiB,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,wBAAwB,EAAE,OAAO,CAAC;IAClC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsalB"}
|