@fitlab-ai/agent-infra 0.8.4 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.ts +2 -2
- package/dist/bin/cli.js +2 -2
- package/dist/bin/internal-cli.js +98 -0
- package/dist/lib/decide.js +81 -90
- package/dist/lib/defaults.json +9 -0
- package/dist/lib/git/review-snapshot.js +79 -0
- package/dist/lib/git/workflow.js +101 -0
- package/dist/lib/init.js +5 -0
- package/dist/lib/internal/git-workflow.js +42 -0
- package/dist/lib/internal/platform-checks.js +119 -0
- package/dist/lib/internal/platform-comment.js +129 -0
- package/dist/lib/internal/platform-context.js +46 -0
- package/dist/lib/internal/platform-issue.js +142 -0
- package/dist/lib/internal/platform-pr.js +146 -0
- package/dist/lib/internal/release-workflow.js +217 -0
- package/dist/lib/internal/task-artifact.js +67 -0
- package/dist/lib/internal/task-context.js +43 -0
- package/dist/lib/internal/task-event.js +70 -0
- package/dist/lib/internal/task-ledger.js +114 -0
- package/dist/lib/internal/task-lifecycle.js +58 -0
- package/dist/lib/internal/task-short-id.js +83 -0
- package/dist/lib/internal/task-snapshot.js +47 -0
- package/dist/lib/internal/task-verify.js +50 -0
- package/dist/lib/internal/task-warning.js +74 -0
- package/dist/lib/platform/adapters.js +14 -0
- package/dist/lib/platform/context.js +146 -0
- package/dist/lib/platform/github-client.js +124 -0
- package/dist/lib/platform/issue-comments.js +409 -0
- package/dist/lib/platform/issue-metadata.js +183 -0
- package/dist/lib/platform/issues.js +617 -0
- package/dist/lib/platform/metadata-labels.js +28 -0
- package/dist/lib/platform/pr-checks.js +216 -0
- package/dist/lib/platform/pr-summary.js +88 -0
- package/dist/lib/platform/pull-request-metadata.js +38 -0
- package/dist/lib/platform/pull-requests.js +338 -0
- package/dist/lib/platform/releases.js +82 -0
- package/dist/lib/platform/types.js +22 -0
- package/dist/lib/platform/verification-required.js +78 -0
- package/dist/lib/platform/verification-sync.js +1014 -0
- package/dist/lib/platform/verification.js +6 -0
- package/dist/lib/release/channels.js +31 -0
- package/dist/lib/release/workflow.js +32 -0
- package/dist/lib/render.js +3 -2
- package/dist/lib/run/index.js +24 -7
- package/dist/lib/sandbox/capture.js +25 -3
- package/dist/lib/sandbox/commands/create.js +66 -26
- package/dist/lib/sandbox/commands/enter.js +34 -11
- package/dist/lib/sandbox/commands/list-running.js +10 -8
- package/dist/lib/sandbox/commands/show.js +2 -2
- package/dist/lib/sandbox/commands/start.js +53 -15
- package/dist/lib/sandbox/engine.js +33 -3
- package/dist/lib/sandbox/engines/colima.js +2 -2
- package/dist/lib/sandbox/index.js +6 -6
- package/dist/lib/sandbox/mounts.js +36 -0
- package/dist/lib/sandbox/recovery.js +562 -0
- package/dist/lib/sandbox/runtimes/base.dockerfile +4 -0
- package/dist/lib/sandbox/task-resolver.js +5 -1
- package/dist/lib/sandbox/tools.js +19 -0
- package/dist/lib/server/daemon.js +9 -0
- package/dist/lib/server/process-control.js +66 -73
- package/dist/lib/server/process-state.js +168 -0
- package/dist/lib/server/protocol.js +5 -5
- package/dist/lib/task/activity-log.js +61 -0
- package/dist/lib/task/artifact-lifecycle.js +427 -0
- package/dist/lib/task/command-options.js +30 -0
- package/dist/lib/task/commands/cat.js +36 -6
- package/dist/lib/task/commands/decisions.js +80 -46
- package/dist/lib/task/commands/files.js +21 -7
- package/dist/lib/task/commands/grep.js +55 -7
- package/dist/lib/task/commands/issue-body.js +23 -14
- package/dist/lib/task/commands/log.js +27 -70
- package/dist/lib/task/commands/show.js +20 -7
- package/dist/lib/task/commands/status.js +18 -8
- package/dist/lib/task/decision-intents.js +154 -0
- package/dist/lib/task/decision-items.js +53 -0
- package/dist/lib/task/events.js +318 -0
- package/dist/lib/task/frontmatter.js +159 -1
- package/dist/lib/task/implementation-inputs.js +117 -0
- package/dist/lib/task/index.js +12 -9
- package/dist/lib/task/issue-form.js +19 -6
- package/dist/lib/task/ledger-intents.js +185 -0
- package/dist/lib/task/ledger.js +65 -35
- package/dist/lib/task/lifecycle.js +484 -0
- package/dist/lib/task/resolve-ref.js +152 -32
- package/dist/lib/task/review-artifacts.js +101 -0
- package/dist/lib/task/review-fingerprint.js +46 -0
- package/dist/lib/task/sections.js +358 -4
- package/dist/lib/task/short-id.js +292 -7
- package/dist/lib/task/snapshot.js +95 -0
- package/dist/lib/task/verification-checks.js +8 -0
- package/dist/lib/task/verification-config.js +14 -0
- package/dist/lib/task/verification-engine.js +906 -0
- package/dist/lib/task/verification-review.js +3 -0
- package/dist/lib/task/verification-types.js +2 -0
- package/dist/lib/task/verification.js +113 -0
- package/dist/lib/task/workflow-warning-intents.js +131 -0
- package/dist/lib/task/workflow-warnings.js +10 -78
- package/dist/lib/task/write.js +241 -0
- package/dist/lib/update.js +2 -0
- package/lib/decide.ts +57 -97
- package/lib/defaults.json +9 -0
- package/lib/git/review-snapshot.ts +73 -0
- package/lib/git/workflow.ts +101 -0
- package/lib/init.ts +9 -0
- package/lib/internal/git-workflow.ts +37 -0
- package/lib/internal/platform-checks.ts +101 -0
- package/lib/internal/platform-comment.ts +99 -0
- package/lib/internal/platform-context.ts +33 -0
- package/lib/internal/platform-issue.ts +116 -0
- package/lib/internal/platform-pr.ts +119 -0
- package/lib/internal/release-workflow.ts +186 -0
- package/lib/internal/task-artifact.ts +47 -0
- package/lib/internal/task-context.ts +35 -0
- package/lib/internal/task-event.ts +51 -0
- package/lib/internal/task-ledger.ts +86 -0
- package/lib/internal/task-lifecycle.ts +41 -0
- package/lib/internal/task-short-id.ts +55 -0
- package/lib/internal/task-snapshot.ts +32 -0
- package/lib/internal/task-verify.ts +33 -0
- package/lib/internal/task-warning.ts +50 -0
- package/lib/platform/adapters.ts +30 -0
- package/lib/platform/context.ts +164 -0
- package/lib/platform/github-client.ts +146 -0
- package/lib/platform/issue-comments.ts +479 -0
- package/lib/platform/issue-metadata.ts +250 -0
- package/lib/platform/issues.ts +691 -0
- package/lib/platform/metadata-labels.ts +33 -0
- package/lib/platform/pr-checks.ts +246 -0
- package/lib/platform/pr-summary.ts +90 -0
- package/lib/platform/pull-request-metadata.ts +69 -0
- package/lib/platform/pull-requests.ts +380 -0
- package/lib/platform/releases.ts +71 -0
- package/lib/platform/types.ts +74 -0
- package/lib/platform/verification-required.ts +83 -0
- package/{templates/.agents/scripts/platform-adapters/platform-sync.github.js → lib/platform/verification-sync.ts} +221 -363
- package/lib/platform/verification.ts +11 -0
- package/lib/release/channels.ts +30 -0
- package/lib/release/workflow.ts +31 -0
- package/lib/render.ts +3 -2
- package/lib/run/index.ts +25 -7
- package/lib/sandbox/capture.ts +29 -3
- package/lib/sandbox/commands/create.ts +75 -28
- package/lib/sandbox/commands/enter.ts +38 -11
- package/lib/sandbox/commands/list-running.ts +10 -8
- package/lib/sandbox/commands/show.ts +2 -2
- package/lib/sandbox/commands/start.ts +50 -16
- package/lib/sandbox/engine.ts +37 -3
- package/lib/sandbox/engines/colima.ts +2 -2
- package/lib/sandbox/index.ts +6 -6
- package/lib/sandbox/mounts.ts +55 -0
- package/lib/sandbox/recovery.ts +828 -0
- package/lib/sandbox/runtimes/base.dockerfile +4 -0
- package/lib/sandbox/task-resolver.ts +5 -1
- package/lib/sandbox/tools.ts +31 -0
- package/lib/server/daemon.ts +9 -0
- package/lib/server/process-control.ts +70 -71
- package/lib/server/process-state.ts +183 -0
- package/lib/server/protocol.ts +5 -5
- package/lib/task/activity-log.ts +62 -0
- package/lib/task/artifact-lifecycle.ts +484 -0
- package/lib/task/command-options.ts +32 -0
- package/lib/task/commands/cat.ts +22 -9
- package/lib/task/commands/decisions.ts +49 -47
- package/lib/task/commands/files.ts +14 -6
- package/lib/task/commands/grep.ts +34 -7
- package/lib/task/commands/issue-body.ts +16 -16
- package/lib/task/commands/log.ts +17 -70
- package/lib/task/commands/show.ts +14 -6
- package/lib/task/commands/status.ts +17 -7
- package/lib/task/decision-intents.ts +163 -0
- package/lib/task/decision-items.ts +64 -0
- package/lib/task/events.ts +320 -0
- package/lib/task/frontmatter.ts +202 -2
- package/lib/task/implementation-inputs.ts +137 -0
- package/lib/task/index.ts +12 -9
- package/lib/task/issue-form.ts +20 -6
- package/lib/task/ledger-intents.ts +201 -0
- package/lib/task/ledger.ts +77 -31
- package/lib/task/lifecycle.ts +458 -0
- package/lib/task/resolve-ref.ts +197 -36
- package/{templates/.agents/scripts/lib/review-artifacts.js → lib/task/review-artifacts.ts} +11 -12
- package/{templates/.agents/scripts/lib/post-review-commit.js → lib/task/review-fingerprint.ts} +20 -10
- package/lib/task/sections.ts +486 -4
- package/lib/task/short-id.ts +403 -9
- package/lib/task/snapshot.ts +143 -0
- package/lib/task/verification-checks.ts +9 -0
- package/lib/task/verification-config.ts +20 -0
- package/{templates/.agents/scripts/validate-artifact.js → lib/task/verification-engine.ts} +257 -451
- package/lib/task/verification-review.ts +9 -0
- package/lib/task/verification-types.ts +29 -0
- package/lib/task/verification.ts +156 -0
- package/lib/task/workflow-warning-intents.ts +142 -0
- package/lib/task/workflow-warnings.ts +10 -78
- package/lib/task/write.ts +468 -0
- package/lib/update.ts +6 -0
- package/package.json +5 -2
- package/templates/.agents/README.en.md +6 -3
- package/templates/.agents/README.zh-CN.md +6 -3
- package/templates/.agents/rules/README.en.md +6 -5
- package/templates/.agents/rules/README.zh-CN.md +6 -5
- package/templates/.agents/rules/create-issue.en.md +1 -1
- package/templates/.agents/rules/create-issue.github.en.md +5 -184
- package/templates/.agents/rules/create-issue.github.zh-CN.md +12 -178
- package/templates/.agents/rules/create-issue.zh-CN.md +1 -1
- package/templates/.agents/rules/human-decision-context.en.md +36 -0
- package/templates/.agents/rules/human-decision-context.zh-CN.md +36 -0
- package/templates/.agents/rules/issue-fields.github.en.md +4 -148
- package/templates/.agents/rules/issue-fields.github.zh-CN.md +9 -144
- package/templates/.agents/rules/issue-pr-commands.en.md +43 -3
- package/templates/.agents/rules/issue-pr-commands.github.en.md +15 -220
- package/templates/.agents/rules/issue-pr-commands.github.zh-CN.md +23 -213
- package/templates/.agents/rules/issue-pr-commands.zh-CN.md +45 -3
- package/templates/.agents/rules/issue-sync.en.md +1 -1
- package/templates/.agents/rules/issue-sync.github.en.md +14 -301
- package/templates/.agents/rules/issue-sync.github.zh-CN.md +36 -287
- package/templates/.agents/rules/issue-sync.zh-CN.md +1 -1
- package/templates/.agents/rules/milestone-inference.en.md +1 -1
- package/templates/.agents/rules/milestone-inference.github.en.md +7 -119
- package/templates/.agents/rules/milestone-inference.github.zh-CN.md +8 -108
- package/templates/.agents/rules/milestone-inference.zh-CN.md +1 -1
- package/templates/.agents/rules/next-step-output.en.md +12 -11
- package/templates/.agents/rules/next-step-output.zh-CN.md +12 -11
- package/templates/.agents/rules/no-mid-flow-questions.en.md +3 -3
- package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +3 -3
- package/templates/.agents/rules/pr-checks-commands.en.md +16 -3
- package/templates/.agents/rules/pr-checks-commands.github.en.md +10 -54
- package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +19 -47
- package/templates/.agents/rules/pr-checks-commands.zh-CN.md +30 -3
- package/templates/.agents/rules/pr-sync.en.md +30 -3
- package/templates/.agents/rules/pr-sync.github.en.md +12 -115
- package/templates/.agents/rules/pr-sync.github.zh-CN.md +26 -104
- package/templates/.agents/rules/pr-sync.zh-CN.md +43 -3
- package/templates/.agents/rules/review-handshake.en.md +13 -9
- package/templates/.agents/rules/review-handshake.zh-CN.md +13 -9
- package/templates/.agents/rules/task-management.en.md +11 -2
- package/templates/.agents/rules/task-management.zh-CN.md +11 -3
- package/templates/.agents/rules/task-short-id.en.md +25 -29
- package/templates/.agents/rules/task-short-id.zh-CN.md +20 -23
- package/templates/.agents/scripts/lib/agent-infra-package.js +141 -0
- package/templates/.agents/scripts/task-short-id.js +71 -533
- package/templates/.agents/skills/analyze-task/SKILL.en.md +22 -55
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +26 -59
- package/templates/.agents/skills/analyze-task/config/verify.en.json +1 -3
- package/templates/.agents/skills/analyze-task/config/verify.zh-CN.json +1 -3
- package/templates/.agents/skills/block-task/SKILL.en.md +21 -47
- package/templates/.agents/skills/block-task/SKILL.zh-CN.md +23 -47
- package/templates/.agents/skills/block-task/config/verify.json +1 -2
- package/templates/.agents/skills/cancel-task/SKILL.en.md +16 -45
- package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +16 -45
- package/templates/.agents/skills/cancel-task/config/verify.json +1 -2
- package/templates/.agents/skills/check-task/SKILL.en.md +6 -3
- package/templates/.agents/skills/check-task/SKILL.zh-CN.md +6 -3
- package/templates/.agents/skills/close-codescan/SKILL.en.md +6 -24
- package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +6 -24
- package/templates/.agents/skills/close-dependabot/SKILL.en.md +6 -24
- package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +6 -24
- package/templates/.agents/skills/code-task/SKILL.en.md +22 -35
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +28 -44
- package/templates/.agents/skills/code-task/config/verify.en.json +3 -3
- package/templates/.agents/skills/code-task/config/verify.zh-CN.json +3 -3
- package/templates/.agents/skills/code-task/reference/dual-mode.en.md +13 -9
- package/templates/.agents/skills/code-task/reference/dual-mode.zh-CN.md +13 -9
- package/templates/.agents/skills/code-task/reference/fix-mode.en.md +1 -1
- package/templates/.agents/skills/code-task/reference/fix-mode.zh-CN.md +1 -1
- package/templates/.agents/skills/code-task/reference/report-template.en.md +11 -1
- package/templates/.agents/skills/code-task/reference/report-template.zh-CN.md +11 -1
- package/templates/.agents/skills/commit/SKILL.en.md +18 -14
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +18 -14
- package/templates/.agents/skills/commit/config/verify.json +1 -2
- package/templates/.agents/skills/commit/reference/commit-message.en.md +1 -11
- package/templates/.agents/skills/commit/reference/commit-message.zh-CN.md +1 -11
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.en.md +4 -8
- package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +4 -8
- package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +6 -18
- package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +5 -17
- package/templates/.agents/skills/commit/reference/task-status-update.en.md +42 -2
- package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +42 -2
- package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +13 -36
- package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +13 -36
- package/templates/.agents/skills/complete-manual-validation/config/verify.en.json +1 -3
- package/templates/.agents/skills/complete-manual-validation/config/verify.zh-CN.json +1 -3
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +10 -54
- package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +10 -79
- package/templates/.agents/skills/complete-task/SKILL.en.md +59 -63
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +59 -63
- package/templates/.agents/skills/complete-task/config/verify.en.json +11 -6
- package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +11 -6
- package/templates/.agents/skills/create-pr/SKILL.en.md +19 -44
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +19 -43
- package/templates/.agents/skills/create-pr/config/verify.json +1 -2
- package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +8 -12
- package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +7 -11
- package/templates/.agents/skills/create-task/SKILL.en.md +12 -13
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +12 -13
- package/templates/.agents/skills/create-task/config/verify.json +1 -2
- package/templates/.agents/skills/import-codescan/SKILL.en.md +2 -2
- package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/import-codescan/config/verify.json +1 -2
- package/templates/.agents/skills/import-dependabot/SKILL.en.md +2 -2
- package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/import-dependabot/config/verify.json +1 -2
- package/templates/.agents/skills/import-issue/SKILL.en.md +9 -13
- package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +10 -14
- package/templates/.agents/skills/import-issue/config/verify.json +1 -2
- package/templates/.agents/skills/init-milestones/SKILL.en.md +2 -2
- package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/init-milestones/scripts/init-milestones.github.sh +5 -4
- package/templates/.agents/skills/plan-task/SKILL.en.md +17 -42
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +22 -49
- package/templates/.agents/skills/plan-task/config/verify.en.json +1 -3
- package/templates/.agents/skills/plan-task/config/verify.zh-CN.json +1 -3
- package/templates/.agents/skills/post-release/SKILL.en.md +11 -81
- package/templates/.agents/skills/post-release/SKILL.zh-CN.md +8 -78
- package/templates/.agents/skills/refine-title/SKILL.en.md +1 -1
- package/templates/.agents/skills/refine-title/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/release/SKILL.en.md +16 -163
- package/templates/.agents/skills/release/SKILL.zh-CN.md +15 -162
- package/templates/.agents/skills/restore-task/SKILL.en.md +11 -29
- package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +11 -29
- package/templates/.agents/skills/restore-task/config/verify.json +1 -2
- package/templates/.agents/skills/review-analysis/SKILL.en.md +13 -25
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +13 -33
- package/templates/.agents/skills/review-analysis/config/verify.en.json +3 -4
- package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +3 -4
- package/templates/.agents/skills/review-analysis/reference/output-templates.en.md +9 -12
- package/templates/.agents/skills/review-analysis/reference/output-templates.zh-CN.md +9 -12
- package/templates/.agents/skills/review-analysis/reference/report-template.en.md +9 -2
- package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +9 -2
- package/templates/.agents/skills/review-analysis/reference/review-criteria.en.md +7 -0
- package/templates/.agents/skills/review-analysis/reference/review-criteria.zh-CN.md +7 -0
- package/templates/.agents/skills/review-code/SKILL.en.md +22 -36
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +23 -41
- package/templates/.agents/skills/review-code/config/verify.en.json +5 -5
- package/templates/.agents/skills/review-code/config/verify.zh-CN.json +5 -5
- package/templates/.agents/skills/review-code/reference/output-templates.en.md +56 -18
- package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +56 -18
- package/templates/.agents/skills/review-code/reference/report-template.en.md +12 -4
- package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +12 -4
- package/templates/.agents/skills/review-code/reference/review-criteria.en.md +7 -0
- package/templates/.agents/skills/review-code/reference/review-criteria.zh-CN.md +7 -0
- package/templates/.agents/skills/review-plan/SKILL.en.md +13 -25
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +13 -33
- package/templates/.agents/skills/review-plan/config/verify.en.json +3 -4
- package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +3 -4
- package/templates/.agents/skills/review-plan/reference/output-templates.en.md +9 -12
- package/templates/.agents/skills/review-plan/reference/output-templates.zh-CN.md +9 -12
- package/templates/.agents/skills/review-plan/reference/report-template.en.md +9 -2
- package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +9 -2
- package/templates/.agents/skills/review-plan/reference/review-criteria.en.md +7 -0
- package/templates/.agents/skills/review-plan/reference/review-criteria.zh-CN.md +7 -0
- package/templates/.agents/skills/update-agent-infra/SKILL.en.md +6 -3
- package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +6 -3
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +177 -151
- package/templates/.agents/skills/watch-pr/SKILL.en.md +24 -14
- package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +25 -15
- package/templates/.agents/skills/watch-pr/config/verify.json +1 -2
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +2 -2
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +2 -2
- package/templates/.agents/templates/task.en.md +6 -1
- package/templates/.agents/templates/task.zh-CN.md +6 -1
- package/templates/.claude/commands/analyze-task.en.md +1 -1
- package/templates/.claude/commands/analyze-task.zh-CN.md +1 -1
- package/templates/.claude/commands/block-task.en.md +1 -1
- package/templates/.claude/commands/block-task.zh-CN.md +1 -1
- package/templates/.claude/commands/cancel-task.en.md +1 -1
- package/templates/.claude/commands/cancel-task.zh-CN.md +1 -1
- package/templates/.claude/commands/check-task.en.md +1 -1
- package/templates/.claude/commands/check-task.zh-CN.md +1 -1
- package/templates/.claude/commands/code-task.en.md +1 -1
- package/templates/.claude/commands/code-task.zh-CN.md +1 -1
- package/templates/.claude/commands/commit.en.md +1 -0
- package/templates/.claude/commands/commit.zh-CN.md +1 -0
- package/templates/.claude/commands/complete-manual-validation.en.md +1 -1
- package/templates/.claude/commands/complete-manual-validation.zh-CN.md +1 -1
- package/templates/.claude/commands/complete-task.en.md +1 -1
- package/templates/.claude/commands/complete-task.zh-CN.md +1 -1
- package/templates/.claude/commands/create-pr.en.md +1 -1
- package/templates/.claude/commands/create-pr.zh-CN.md +1 -1
- package/templates/.claude/commands/plan-task.en.md +1 -1
- package/templates/.claude/commands/plan-task.zh-CN.md +1 -1
- package/templates/.claude/commands/review-analysis.en.md +1 -1
- package/templates/.claude/commands/review-analysis.zh-CN.md +1 -1
- package/templates/.claude/commands/review-code.en.md +1 -1
- package/templates/.claude/commands/review-code.zh-CN.md +1 -1
- package/templates/.claude/commands/review-plan.en.md +1 -1
- package/templates/.claude/commands/review-plan.zh-CN.md +1 -1
- package/templates/.claude/commands/watch-pr.en.md +1 -1
- package/templates/.claude/commands/watch-pr.zh-CN.md +1 -1
- package/templates/.gemini/commands/_project_/analyze-task.en.toml +2 -0
- package/templates/.gemini/commands/_project_/analyze-task.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/block-task.en.toml +2 -0
- package/templates/.gemini/commands/_project_/block-task.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/cancel-task.en.toml +2 -0
- package/templates/.gemini/commands/_project_/cancel-task.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/check-task.en.toml +2 -0
- package/templates/.gemini/commands/_project_/check-task.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/code-task.en.toml +2 -0
- package/templates/.gemini/commands/_project_/code-task.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/commit.en.toml +4 -0
- package/templates/.gemini/commands/_project_/commit.zh-CN.toml +4 -0
- package/templates/.gemini/commands/_project_/complete-manual-validation.en.toml +2 -0
- package/templates/.gemini/commands/_project_/complete-manual-validation.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/complete-task.en.toml +2 -0
- package/templates/.gemini/commands/_project_/complete-task.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/create-pr.en.toml +2 -0
- package/templates/.gemini/commands/_project_/create-pr.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/plan-task.en.toml +2 -0
- package/templates/.gemini/commands/_project_/plan-task.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/review-analysis.en.toml +2 -0
- package/templates/.gemini/commands/_project_/review-analysis.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/review-code.en.toml +2 -0
- package/templates/.gemini/commands/_project_/review-code.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/review-plan.en.toml +2 -0
- package/templates/.gemini/commands/_project_/review-plan.zh-CN.toml +2 -0
- package/templates/.gemini/commands/_project_/watch-pr.en.toml +2 -0
- package/templates/.gemini/commands/_project_/watch-pr.zh-CN.toml +2 -0
- package/templates/.git-hooks/check-large-files.cjs +92 -0
- package/templates/.git-hooks/check-version-format.sh +5 -1
- package/templates/.git-hooks/pre-commit +1 -0
- package/templates/.opencode/commands/analyze-task.en.md +1 -1
- package/templates/.opencode/commands/analyze-task.zh-CN.md +1 -1
- package/templates/.opencode/commands/check-task.en.md +1 -1
- package/templates/.opencode/commands/check-task.zh-CN.md +1 -1
- package/templates/.opencode/commands/code-task.en.md +1 -1
- package/templates/.opencode/commands/code-task.zh-CN.md +1 -1
- package/templates/.opencode/commands/commit.en.md +2 -0
- package/templates/.opencode/commands/commit.zh-CN.md +2 -0
- package/templates/.opencode/commands/complete-task.en.md +1 -1
- package/templates/.opencode/commands/complete-task.zh-CN.md +1 -1
- package/templates/.opencode/commands/plan-task.en.md +1 -1
- package/templates/.opencode/commands/plan-task.zh-CN.md +1 -1
- package/templates/.opencode/commands/review-analysis.en.md +1 -1
- package/templates/.opencode/commands/review-analysis.zh-CN.md +1 -1
- package/templates/.opencode/commands/review-code.en.md +1 -1
- package/templates/.opencode/commands/review-code.zh-CN.md +1 -1
- package/templates/.opencode/commands/review-plan.en.md +1 -1
- package/templates/.opencode/commands/review-plan.zh-CN.md +1 -1
- package/templates/.agents/scripts/platform-adapters/platform-sync.js +0 -13
- package/templates/.agents/scripts/review-diff-fingerprint.js +0 -99
- package/templates/.agents/scripts/workflow-warnings.js +0 -290
- package/templates/.agents/skills/code-task/scripts/detect-mode.js +0 -257
- package/templates/.agents/skills/release/scripts/manage-milestones.github.sh +0 -80
- package/templates/.agents/skills/release/scripts/manage-milestones.sh +0 -6
|
@@ -1,66 +1,44 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
2
|
import { spawn, execFileSync } from 'node:child_process';
|
|
4
3
|
import { loadServerConfig } from './config.js';
|
|
5
4
|
import { runDaemon } from './daemon.js';
|
|
5
|
+
import { getProcessStartTime, isProcessAlive, processIdentityMatches, readProcessState, removePidFileIfMatches, writePidRecord } from './process-state.js';
|
|
6
|
+
export { isProcessAlive } from './process-state.js';
|
|
6
7
|
export function buildStopCommand(pid, platform) {
|
|
7
8
|
if (platform === 'win32') {
|
|
8
9
|
return { kind: 'exec', command: 'taskkill', args: ['/PID', String(pid), '/T', '/F'] };
|
|
9
10
|
}
|
|
10
11
|
return { kind: 'signal', signal: 'SIGTERM' };
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// reaps the zombie. On Linux we therefore also check /proc state so status/stop
|
|
17
|
-
// /start don't treat an already-exited daemon as running. macOS reaps orphans
|
|
18
|
-
// via launchd and Windows has no zombies, so the kill(pid, 0) result is enough.
|
|
19
|
-
export function isProcessAlive(pid) {
|
|
20
|
-
try {
|
|
21
|
-
process.kill(pid, 0);
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
// EPERM means the process exists but we may not signal it → still alive.
|
|
25
|
-
return error.code === 'EPERM';
|
|
26
|
-
}
|
|
27
|
-
if (process.platform === 'linux') {
|
|
28
|
-
try {
|
|
29
|
-
const stat = fs.readFileSync(`/proc/${pid}/stat`, 'utf8');
|
|
30
|
-
// The process state is the first token after the parenthesised comm.
|
|
31
|
-
const state = stat.slice(stat.lastIndexOf(')') + 1).trim().charAt(0);
|
|
32
|
-
if (state === 'Z')
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return false; // /proc entry vanished → not alive
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return true;
|
|
13
|
+
function delay(ms) {
|
|
14
|
+
return new Promise((resolve) => {
|
|
15
|
+
setTimeout(resolve, ms);
|
|
16
|
+
});
|
|
40
17
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
18
|
+
async function waitForProcessIdentity(pid, timeoutMs = 2000) {
|
|
19
|
+
const deadline = Date.now() + timeoutMs;
|
|
20
|
+
while (Date.now() < deadline) {
|
|
21
|
+
const startTime = getProcessStartTime(pid);
|
|
22
|
+
if (startTime !== null)
|
|
23
|
+
return { version: 1, pid, startTime };
|
|
24
|
+
await delay(25);
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
50
27
|
}
|
|
51
|
-
function
|
|
28
|
+
function terminateIfMatching(record) {
|
|
29
|
+
if (!processIdentityMatches(record))
|
|
30
|
+
return;
|
|
31
|
+
const command = buildStopCommand(record.pid, process.platform);
|
|
52
32
|
try {
|
|
53
|
-
|
|
33
|
+
if (command.kind === 'exec')
|
|
34
|
+
execFileSync(command.command, command.args);
|
|
35
|
+
else
|
|
36
|
+
process.kill(record.pid, command.signal);
|
|
54
37
|
}
|
|
55
38
|
catch {
|
|
56
|
-
//
|
|
39
|
+
// Best effort cleanup for a daemon whose PID record could not be published.
|
|
57
40
|
}
|
|
58
41
|
}
|
|
59
|
-
function delay(ms) {
|
|
60
|
-
return new Promise((resolve) => {
|
|
61
|
-
setTimeout(resolve, ms);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
42
|
function enabledAdapterNames(config) {
|
|
65
43
|
return Object.entries(config.adapters)
|
|
66
44
|
.filter(([, adapter]) => adapter?.enabled === true)
|
|
@@ -69,15 +47,13 @@ function enabledAdapterNames(config) {
|
|
|
69
47
|
export async function start({ foreground = false } = {}) {
|
|
70
48
|
const config = loadServerConfig();
|
|
71
49
|
const pidPath = config.pidFile;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (existing !== null && isProcessAlive(existing)) {
|
|
76
|
-
process.stdout.write(`server already running (pid ${existing})\n`);
|
|
50
|
+
const existing = readProcessState(pidPath);
|
|
51
|
+
if (existing.kind === 'running') {
|
|
52
|
+
process.stdout.write(`server already running (pid ${existing.record.pid})\n`);
|
|
77
53
|
return;
|
|
78
54
|
}
|
|
79
|
-
if (existing !==
|
|
80
|
-
|
|
55
|
+
if (existing.kind !== 'missing') {
|
|
56
|
+
removePidFileIfMatches(pidPath, existing.snapshot);
|
|
81
57
|
}
|
|
82
58
|
if (foreground) {
|
|
83
59
|
await runDaemon();
|
|
@@ -98,47 +74,64 @@ export async function start({ foreground = false } = {}) {
|
|
|
98
74
|
if (typeof child.pid !== 'number') {
|
|
99
75
|
throw new Error('server: failed to spawn daemon process');
|
|
100
76
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
77
|
+
// The initial check, spawn, and record publication are not a mutually
|
|
78
|
+
// exclusive transaction. Atomic publication keeps the record complete, but
|
|
79
|
+
// a separate locking design is required to serialize concurrent starts.
|
|
80
|
+
const record = await waitForProcessIdentity(child.pid);
|
|
81
|
+
if (record === null || !processIdentityMatches(record)) {
|
|
82
|
+
throw new Error('server: unable to verify spawned daemon process identity');
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
writePidRecord(pidPath, record);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
terminateIfMatching(record);
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
process.stdout.write(`server started (pid ${record.pid})\n`);
|
|
104
92
|
}
|
|
105
93
|
export async function stop() {
|
|
106
94
|
const config = loadServerConfig();
|
|
107
|
-
const
|
|
108
|
-
if (
|
|
95
|
+
const state = readProcessState(config.pidFile);
|
|
96
|
+
if (state.kind === 'missing') {
|
|
109
97
|
process.stdout.write('server is not running (no pid file)\n');
|
|
110
98
|
return;
|
|
111
99
|
}
|
|
112
|
-
if (
|
|
113
|
-
|
|
100
|
+
if (state.kind !== 'running') {
|
|
101
|
+
removePidFileIfMatches(config.pidFile, state.snapshot);
|
|
114
102
|
process.stdout.write('server is not running (removed stale pid file)\n');
|
|
115
103
|
return;
|
|
116
104
|
}
|
|
117
|
-
const
|
|
105
|
+
const { record } = state;
|
|
106
|
+
if (!processIdentityMatches(record)) {
|
|
107
|
+
removePidFileIfMatches(config.pidFile, state.snapshot);
|
|
108
|
+
process.stdout.write('server is not running (removed stale pid file)\n');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const command = buildStopCommand(record.pid, process.platform);
|
|
118
112
|
if (command.kind === 'exec') {
|
|
119
113
|
execFileSync(command.command, command.args);
|
|
120
114
|
}
|
|
121
115
|
else {
|
|
122
|
-
process.kill(pid, command.signal);
|
|
116
|
+
process.kill(record.pid, command.signal);
|
|
123
117
|
const deadline = Date.now() + 5000;
|
|
124
|
-
while (isProcessAlive(pid) && Date.now() < deadline) {
|
|
118
|
+
while (isProcessAlive(record.pid) && Date.now() < deadline) {
|
|
125
119
|
await delay(100);
|
|
126
120
|
}
|
|
127
|
-
if (isProcessAlive(pid)) {
|
|
128
|
-
process.kill(pid, 'SIGKILL');
|
|
121
|
+
if (isProcessAlive(record.pid) && processIdentityMatches(record)) {
|
|
122
|
+
process.kill(record.pid, 'SIGKILL');
|
|
129
123
|
}
|
|
130
124
|
}
|
|
131
|
-
|
|
132
|
-
process.stdout.write(`server stopped (pid ${pid})\n`);
|
|
125
|
+
removePidFileIfMatches(config.pidFile, state.snapshot);
|
|
126
|
+
process.stdout.write(`server stopped (pid ${record.pid})\n`);
|
|
133
127
|
}
|
|
134
128
|
export function status() {
|
|
135
129
|
const config = loadServerConfig();
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
130
|
+
const state = readProcessState(config.pidFile);
|
|
131
|
+
if (state.kind !== 'running') {
|
|
132
|
+
if (state.kind !== 'missing')
|
|
133
|
+
removePidFileIfMatches(config.pidFile, state.snapshot);
|
|
138
134
|
process.stdout.write('server: stopped\n');
|
|
139
|
-
if (pid !== null) {
|
|
140
|
-
process.stdout.write(` (stale pid file references pid ${pid})\n`);
|
|
141
|
-
}
|
|
142
135
|
return;
|
|
143
136
|
}
|
|
144
137
|
let startedAt = 'unknown';
|
|
@@ -150,7 +143,7 @@ export function status() {
|
|
|
150
143
|
}
|
|
151
144
|
const adapters = enabledAdapterNames(config);
|
|
152
145
|
process.stdout.write(`server: running\n` +
|
|
153
|
-
` pid: ${pid}\n` +
|
|
146
|
+
` pid: ${state.record.pid}\n` +
|
|
154
147
|
` started: ${startedAt}\n` +
|
|
155
148
|
` adapters: ${adapters.length > 0 ? adapters.join(', ') : '(none)'}\n` +
|
|
156
149
|
` pid file: ${config.pidFile}\n` +
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
export function parseLinuxProcessStat(raw) {
|
|
5
|
+
const closeParen = raw.lastIndexOf(')');
|
|
6
|
+
if (closeParen < 0)
|
|
7
|
+
return null;
|
|
8
|
+
const fields = raw.slice(closeParen + 1).trim().split(/\s+/);
|
|
9
|
+
const state = fields[0];
|
|
10
|
+
const startTime = fields[19];
|
|
11
|
+
if (typeof state !== 'string' || state.length !== 1 || !/^\d+$/.test(startTime ?? '')) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return { state, startTime: startTime };
|
|
15
|
+
}
|
|
16
|
+
export function buildProcessStartTimeQuery(pid, platform) {
|
|
17
|
+
if (platform === 'darwin') {
|
|
18
|
+
return { command: 'ps', args: ['-p', String(pid), '-o', 'lstart='] };
|
|
19
|
+
}
|
|
20
|
+
if (platform === 'win32') {
|
|
21
|
+
const script = `$process = Get-CimInstance Win32_Process -Filter 'ProcessId = ${pid}'; ` +
|
|
22
|
+
`if ($null -ne $process) { $process.CreationDate.ToUniversalTime().ToString('o') }`;
|
|
23
|
+
return {
|
|
24
|
+
command: 'powershell.exe',
|
|
25
|
+
args: ['-NoProfile', '-NonInteractive', '-Command', script]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
export function isProcessAlive(pid, platform = process.platform) {
|
|
31
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
32
|
+
return false;
|
|
33
|
+
if (platform === 'linux') {
|
|
34
|
+
try {
|
|
35
|
+
const stat = parseLinuxProcessStat(fs.readFileSync(`/proc/${pid}/stat`, 'utf8'));
|
|
36
|
+
return stat !== null && stat.state !== 'Z';
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
process.kill(pid, 0);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return error.code === 'EPERM';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export function getProcessStartTime(pid, platform = process.platform) {
|
|
51
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
52
|
+
return null;
|
|
53
|
+
if (platform === 'linux') {
|
|
54
|
+
try {
|
|
55
|
+
const stat = parseLinuxProcessStat(fs.readFileSync(`/proc/${pid}/stat`, 'utf8'));
|
|
56
|
+
return stat !== null && stat.state !== 'Z' ? stat.startTime : null;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (!isProcessAlive(pid, platform))
|
|
63
|
+
return null;
|
|
64
|
+
const query = buildProcessStartTimeQuery(pid, platform);
|
|
65
|
+
if (query === null)
|
|
66
|
+
return null;
|
|
67
|
+
try {
|
|
68
|
+
const output = execFileSync(query.command, query.args, { encoding: 'utf8' }).trim();
|
|
69
|
+
if (output.length === 0)
|
|
70
|
+
return null;
|
|
71
|
+
if (platform === 'win32') {
|
|
72
|
+
const timestamp = new Date(output);
|
|
73
|
+
return Number.isNaN(timestamp.getTime()) ? null : timestamp.toISOString();
|
|
74
|
+
}
|
|
75
|
+
return output;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function parsePidRecord(raw) {
|
|
82
|
+
const trimmed = raw.trim();
|
|
83
|
+
if (/^[1-9]\d*$/.test(trimmed)) {
|
|
84
|
+
const pid = Number(trimmed);
|
|
85
|
+
return Number.isSafeInteger(pid) ? { kind: 'legacy', pid } : { kind: 'invalid' };
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const value = JSON.parse(trimmed);
|
|
89
|
+
if (value !== null &&
|
|
90
|
+
value.version === 1 &&
|
|
91
|
+
Number.isSafeInteger(value.pid) &&
|
|
92
|
+
(value.pid ?? 0) > 0 &&
|
|
93
|
+
typeof value.startTime === 'string' &&
|
|
94
|
+
value.startTime.length > 0) {
|
|
95
|
+
return {
|
|
96
|
+
kind: 'record',
|
|
97
|
+
record: { version: 1, pid: value.pid, startTime: value.startTime }
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// Invalid JSON is an invalid PID record.
|
|
103
|
+
}
|
|
104
|
+
return { kind: 'invalid' };
|
|
105
|
+
}
|
|
106
|
+
export function readProcessState(pidFile) {
|
|
107
|
+
let snapshot;
|
|
108
|
+
try {
|
|
109
|
+
snapshot = fs.readFileSync(pidFile, 'utf8');
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
if (error.code === 'ENOENT')
|
|
113
|
+
return { kind: 'missing', snapshot: null };
|
|
114
|
+
return { kind: 'invalid', snapshot: '' };
|
|
115
|
+
}
|
|
116
|
+
const parsed = parsePidRecord(snapshot);
|
|
117
|
+
if (parsed.kind === 'invalid')
|
|
118
|
+
return { kind: 'invalid', snapshot };
|
|
119
|
+
if (parsed.kind === 'legacy')
|
|
120
|
+
return { kind: 'legacy', snapshot, pid: parsed.pid };
|
|
121
|
+
const currentStartTime = getProcessStartTime(parsed.record.pid);
|
|
122
|
+
if (currentStartTime === null || currentStartTime !== parsed.record.startTime) {
|
|
123
|
+
return { kind: 'stale', snapshot, record: parsed.record };
|
|
124
|
+
}
|
|
125
|
+
return { kind: 'running', snapshot, record: parsed.record };
|
|
126
|
+
}
|
|
127
|
+
export function writePidRecord(pidFile, record) {
|
|
128
|
+
fs.mkdirSync(path.dirname(pidFile), { recursive: true });
|
|
129
|
+
const temporary = `${pidFile}.${process.pid}.${Math.random().toString(16).slice(2)}.tmp`;
|
|
130
|
+
try {
|
|
131
|
+
fs.writeFileSync(temporary, `${JSON.stringify(record)}\n`);
|
|
132
|
+
fs.renameSync(temporary, pidFile);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
try {
|
|
136
|
+
fs.unlinkSync(temporary);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
// The temporary file was never created or was already renamed.
|
|
140
|
+
}
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export function removePidFileIfMatches(pidFile, expectedSnapshot) {
|
|
145
|
+
if (expectedSnapshot === null)
|
|
146
|
+
return false;
|
|
147
|
+
try {
|
|
148
|
+
if (fs.readFileSync(pidFile, 'utf8') !== expectedSnapshot)
|
|
149
|
+
return false;
|
|
150
|
+
fs.unlinkSync(pidFile);
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
export function removePidRecordIfMatches(pidFile, expected) {
|
|
158
|
+
const state = readProcessState(pidFile);
|
|
159
|
+
if (state.kind !== 'running')
|
|
160
|
+
return false;
|
|
161
|
+
if (state.record.pid !== expected.pid || state.record.startTime !== expected.startTime)
|
|
162
|
+
return false;
|
|
163
|
+
return removePidFileIfMatches(pidFile, state.snapshot);
|
|
164
|
+
}
|
|
165
|
+
export function processIdentityMatches(record) {
|
|
166
|
+
return getProcessStartTime(record.pid) === record.startTime;
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=process-state.js.map
|
|
@@ -20,16 +20,16 @@ export function commandHelp() {
|
|
|
20
20
|
'/sandbox ls',
|
|
21
21
|
'/sandbox show {ref}',
|
|
22
22
|
'/sandbox vm status',
|
|
23
|
-
'/task decisions {ref}',
|
|
24
|
-
'/task log {ref}',
|
|
23
|
+
'/task decisions [--task {ref}] [--item {selector}]',
|
|
24
|
+
'/task log [--task {ref}]',
|
|
25
25
|
'/task ls',
|
|
26
|
-
'/task show {ref}',
|
|
27
|
-
'/task status {ref}',
|
|
26
|
+
'/task show [--task {ref}]',
|
|
27
|
+
'/task status [--task {ref}]',
|
|
28
28
|
'Write:',
|
|
29
29
|
'/sandbox create {ref}',
|
|
30
30
|
'/sandbox start {ref}',
|
|
31
31
|
'Exec:',
|
|
32
|
-
'/decide {
|
|
32
|
+
'/decide [--task {ref}] --item {ordinal|ledger-id} [--needs-implementation true|false] {decision}',
|
|
33
33
|
'/run create-task {description}',
|
|
34
34
|
'/run {skill} {task-ref}'
|
|
35
35
|
].join('\n');
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const HEADING_RE = /^##\s+(活动日志|Activity Log)\s*$/;
|
|
2
|
+
const NEXT_H2_RE = /^##\s/;
|
|
3
|
+
const ENTRY_RE = /^- (\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}) — \*\*(.+?)\*\* by (.+?) — (.*)$/;
|
|
4
|
+
const STARTED_SUFFIX_RE = /\s*\[started\]\s*$/;
|
|
5
|
+
function parseActivityLog(content) {
|
|
6
|
+
const section = locateActivityLog(content);
|
|
7
|
+
return section ? { sectionFound: true, entries: section.entries } : { sectionFound: false, entries: [] };
|
|
8
|
+
}
|
|
9
|
+
function locateActivityLog(content) {
|
|
10
|
+
const lines = content.split('\n');
|
|
11
|
+
const headings = lines.map((line, index) => HEADING_RE.test(line) ? index : -1).filter((index) => index >= 0);
|
|
12
|
+
if (headings.length !== 1)
|
|
13
|
+
return null;
|
|
14
|
+
const i = headings[0];
|
|
15
|
+
let end = lines.length;
|
|
16
|
+
for (let j = i + 1; j < lines.length; j += 1) {
|
|
17
|
+
if (NEXT_H2_RE.test(lines[j])) {
|
|
18
|
+
end = j;
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const bodyLines = lines.slice(i + 1, end);
|
|
23
|
+
const parsed = [];
|
|
24
|
+
for (const line of bodyLines) {
|
|
25
|
+
const m = ENTRY_RE.exec(line);
|
|
26
|
+
if (!m)
|
|
27
|
+
continue;
|
|
28
|
+
parsed.push({ entry: { time: m[1], step: m[2], agent: m[3], note: m[4] }, epoch: Date.parse(m[1].replace(' ', 'T')), order: parsed.length });
|
|
29
|
+
}
|
|
30
|
+
parsed.sort((a, b) => a.epoch - b.epoch || a.order - b.order);
|
|
31
|
+
return { heading: HEADING_RE.exec(lines[i])[1], body: bodyLines.join('\n').replace(/^\n+|\n+$/g, ''), entries: parsed.map((item) => item.entry) };
|
|
32
|
+
}
|
|
33
|
+
function appendActivityEntry(section, entry) {
|
|
34
|
+
const line = `- ${entry.time} — **${entry.step}** by ${entry.agent} — ${entry.note}`;
|
|
35
|
+
return section.body ? `${section.body}\n${line}` : line;
|
|
36
|
+
}
|
|
37
|
+
function pairEntries(entries) {
|
|
38
|
+
const rows = [];
|
|
39
|
+
const open = new Map();
|
|
40
|
+
for (const entry of entries) {
|
|
41
|
+
const started = STARTED_SUFFIX_RE.test(entry.step);
|
|
42
|
+
const base = entry.step.replace(STARTED_SUFFIX_RE, '');
|
|
43
|
+
if (started) {
|
|
44
|
+
const row = { step: base, agent: entry.agent, started: entry.time, done: '', note: entry.note };
|
|
45
|
+
rows.push(row);
|
|
46
|
+
const queue = open.get(base) ?? [];
|
|
47
|
+
queue.push(row);
|
|
48
|
+
open.set(base, queue);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const pending = open.get(base)?.shift();
|
|
52
|
+
if (pending)
|
|
53
|
+
Object.assign(pending, { done: entry.time, agent: entry.agent, note: entry.note });
|
|
54
|
+
else
|
|
55
|
+
rows.push({ step: base, agent: entry.agent, started: '', done: entry.time, note: entry.note });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return rows;
|
|
59
|
+
}
|
|
60
|
+
export { parseActivityLog, locateActivityLog, appendActivityEntry, pairEntries };
|
|
61
|
+
//# sourceMappingURL=activity-log.js.map
|