@phnx-labs/agents-cli 1.12.0 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/README.md +293 -300
- package/dist/commands/alias.d.ts +11 -0
- package/dist/commands/alias.js +117 -0
- package/dist/commands/beta.d.ts +2 -0
- package/dist/commands/beta.js +53 -0
- package/dist/commands/cloud.d.ts +10 -0
- package/dist/commands/cloud.js +408 -0
- package/dist/commands/commands.d.ts +9 -1
- package/dist/commands/commands.js +24 -172
- package/dist/commands/daemon.d.ts +8 -1
- package/dist/commands/daemon.js +13 -5
- package/dist/commands/doctor.d.ts +15 -0
- package/dist/commands/doctor.js +132 -0
- package/dist/commands/drive.d.ts +8 -1
- package/dist/commands/drive.js +20 -3
- package/dist/commands/exec.d.ts +8 -1
- package/dist/commands/exec.js +207 -20
- package/dist/commands/factory.d.ts +19 -0
- package/dist/commands/factory.js +71 -0
- package/dist/commands/fork.d.ts +8 -1
- package/dist/commands/fork.js +11 -4
- package/dist/commands/hooks.d.ts +9 -1
- package/dist/commands/hooks.js +30 -182
- package/dist/commands/init.d.ts +15 -1
- package/dist/commands/init.js +168 -74
- package/dist/commands/mcp.d.ts +9 -1
- package/dist/commands/mcp.js +11 -7
- package/dist/commands/models.d.ts +8 -1
- package/dist/commands/models.js +45 -6
- package/dist/commands/packages.d.ts +8 -1
- package/dist/commands/packages.js +13 -7
- package/dist/commands/permissions.d.ts +9 -1
- package/dist/commands/permissions.js +3 -3
- package/dist/commands/plugins.d.ts +8 -1
- package/dist/commands/plugins.js +13 -2
- package/dist/commands/profiles.d.ts +11 -0
- package/dist/commands/profiles.js +291 -0
- package/dist/commands/prune.d.ts +22 -0
- package/dist/commands/prune.js +191 -0
- package/dist/commands/pty.d.ts +1 -1
- package/dist/commands/pty.js +2 -1
- package/dist/commands/pull.d.ts +8 -1
- package/dist/commands/pull.js +93 -129
- package/dist/commands/refresh-memory.d.ts +7 -1
- package/dist/commands/refresh-memory.js +7 -1
- package/dist/commands/repo.d.ts +15 -0
- package/dist/commands/repo.js +570 -0
- package/dist/commands/resource-view.d.ts +10 -3
- package/dist/commands/resource-view.js +18 -5
- package/dist/commands/routines.d.ts +8 -1
- package/dist/commands/routines.js +17 -4
- package/dist/commands/rules.d.ts +9 -1
- package/dist/commands/rules.js +16 -11
- package/dist/commands/secrets.d.ts +10 -0
- package/dist/commands/secrets.js +511 -0
- package/dist/commands/sessions-picker.d.ts +2 -1
- package/dist/commands/sessions-picker.js +88 -11
- package/dist/commands/sessions-tail.d.ts +19 -0
- package/dist/commands/sessions-tail.js +235 -0
- package/dist/commands/sessions.d.ts +2 -1
- package/dist/commands/sessions.js +288 -7
- package/dist/commands/skills.d.ts +9 -1
- package/dist/commands/skills.js +28 -178
- package/dist/commands/status.d.ts +7 -1
- package/dist/commands/status.js +7 -1
- package/dist/commands/subagents.d.ts +8 -1
- package/dist/commands/subagents.js +11 -1
- package/dist/commands/sync.d.ts +8 -1
- package/dist/commands/sync.js +8 -1
- package/dist/commands/teams-picker.d.ts +4 -1
- package/dist/commands/teams-picker.js +55 -3
- package/dist/commands/teams.d.ts +15 -1
- package/dist/commands/teams.js +323 -69
- package/dist/commands/usage.d.ts +11 -0
- package/dist/commands/usage.js +60 -0
- package/dist/commands/utils.d.ts +6 -1
- package/dist/commands/utils.js +6 -1
- package/dist/commands/versions.d.ts +8 -1
- package/dist/commands/versions.js +4 -3
- package/dist/commands/view.d.ts +47 -2
- package/dist/commands/view.js +353 -20
- package/dist/index.d.ts +7 -2
- package/dist/index.js +205 -38
- package/dist/lib/acp/client.d.ts +31 -0
- package/dist/lib/acp/client.js +117 -0
- package/dist/lib/acp/harnesses.d.ts +26 -0
- package/dist/lib/acp/harnesses.js +65 -0
- package/dist/lib/acp/run.d.ts +18 -0
- package/dist/lib/acp/run.js +39 -0
- package/dist/lib/agents.d.ts +74 -2
- package/dist/lib/agents.js +207 -23
- package/dist/lib/artifact-actions.d.ts +8 -4
- package/dist/lib/artifact-actions.js +8 -6
- package/dist/lib/auto-pull-worker.d.ts +11 -0
- package/dist/lib/auto-pull-worker.js +121 -0
- package/dist/lib/auto-pull.d.ts +31 -0
- package/dist/lib/auto-pull.js +97 -0
- package/dist/lib/beta.d.ts +23 -0
- package/dist/lib/beta.js +90 -0
- package/dist/lib/capabilities.d.ts +29 -0
- package/dist/lib/capabilities.js +74 -0
- package/dist/lib/cloud/codex.d.ts +25 -0
- package/dist/lib/cloud/codex.js +250 -0
- package/dist/lib/cloud/factory.d.ts +31 -0
- package/dist/lib/cloud/factory.js +53 -0
- package/dist/lib/cloud/registry.d.ts +15 -0
- package/dist/lib/cloud/registry.js +67 -0
- package/dist/lib/cloud/rush.d.ts +75 -0
- package/dist/lib/cloud/rush.js +438 -0
- package/dist/lib/cloud/store.d.ts +22 -0
- package/dist/lib/cloud/store.js +115 -0
- package/dist/lib/cloud/stream.d.ts +23 -0
- package/dist/lib/cloud/stream.js +194 -0
- package/dist/lib/cloud/types.d.ts +205 -0
- package/dist/lib/cloud/types.js +34 -0
- package/dist/lib/command-skills.d.ts +20 -0
- package/dist/lib/command-skills.js +142 -0
- package/dist/lib/commands.d.ts +22 -2
- package/dist/lib/commands.js +51 -11
- package/dist/lib/convert.d.ts +10 -1
- package/dist/lib/convert.js +9 -1
- package/dist/lib/daemon.d.ts +21 -1
- package/dist/lib/daemon.js +97 -4
- package/dist/lib/drive-sync.d.ts +18 -1
- package/dist/lib/drive-sync.js +57 -15
- package/dist/lib/exec.d.ts +25 -5
- package/dist/lib/exec.js +72 -27
- package/dist/lib/fs-walk.d.ts +2 -0
- package/dist/lib/fs-walk.js +40 -0
- package/dist/lib/fuzzy.d.ts +53 -0
- package/dist/lib/fuzzy.js +72 -0
- package/dist/lib/gemini-settings.d.ts +4 -0
- package/dist/lib/gemini-settings.js +33 -0
- package/dist/lib/git.d.ts +12 -2
- package/dist/lib/git.js +17 -6
- package/dist/lib/help.d.ts +20 -1
- package/dist/lib/help.js +45 -6
- package/dist/lib/hooks/match.d.ts +32 -0
- package/dist/lib/hooks/match.js +120 -0
- package/dist/lib/hooks.d.ts +17 -4
- package/dist/lib/hooks.js +191 -21
- package/dist/lib/manifest.d.ts +6 -1
- package/dist/lib/manifest.js +15 -4
- package/dist/lib/markdown.d.ts +0 -1
- package/dist/lib/markdown.js +6 -1
- package/dist/lib/mcp.d.ts +0 -1
- package/dist/lib/mcp.js +29 -33
- package/dist/lib/memory-compile.d.ts +13 -3
- package/dist/lib/memory-compile.js +31 -9
- package/dist/lib/memory.d.ts +14 -7
- package/dist/lib/memory.js +67 -38
- package/dist/lib/migrate.d.ts +8 -0
- package/dist/lib/migrate.js +85 -0
- package/dist/lib/models.d.ts +25 -11
- package/dist/lib/models.js +405 -16
- package/dist/lib/onepassword.d.ts +63 -0
- package/dist/lib/onepassword.js +186 -0
- package/dist/lib/paths.d.ts +8 -0
- package/dist/lib/paths.js +20 -0
- package/dist/lib/permissions.d.ts +24 -2
- package/dist/lib/permissions.js +117 -48
- package/dist/lib/picker.d.ts +10 -1
- package/dist/lib/picker.js +15 -1
- package/dist/lib/plugins.d.ts +7 -1
- package/dist/lib/plugins.js +10 -1
- package/dist/lib/profiles-presets.d.ts +24 -0
- package/dist/lib/profiles-presets.js +103 -0
- package/dist/lib/profiles.d.ts +69 -0
- package/dist/lib/profiles.js +144 -0
- package/dist/lib/pty-client.d.ts +1 -1
- package/dist/lib/pty-client.js +0 -1
- package/dist/lib/pty-server.d.ts +16 -2
- package/dist/lib/pty-server.js +92 -3
- package/dist/lib/registry.d.ts +23 -3
- package/dist/lib/registry.js +153 -8
- package/dist/lib/resources.d.ts +28 -1
- package/dist/lib/resources.js +79 -1
- package/dist/lib/rotate.d.ts +79 -0
- package/dist/lib/rotate.js +285 -0
- package/dist/lib/routines.d.ts +29 -1
- package/dist/lib/routines.js +32 -5
- package/dist/lib/runner.d.ts +14 -1
- package/dist/lib/runner.js +22 -3
- package/dist/lib/sandbox.d.ts +16 -1
- package/dist/lib/sandbox.js +39 -16
- package/dist/lib/scheduler.d.ts +8 -1
- package/dist/lib/scheduler.js +8 -1
- package/dist/lib/secrets/AgentsKeychain.app/Contents/CodeResources +0 -0
- package/dist/lib/secrets/AgentsKeychain.app/Contents/Info.plist +22 -0
- package/dist/lib/secrets/AgentsKeychain.app/Contents/MacOS/AgentsKeychain +0 -0
- package/dist/lib/secrets/AgentsKeychain.app/Contents/_CodeSignature/CodeResources +123 -0
- package/dist/lib/secrets/AgentsKeychain.app/Contents/embedded.provisionprofile +0 -0
- package/dist/lib/secrets/bundles.d.ts +39 -0
- package/dist/lib/secrets/bundles.js +189 -0
- package/dist/lib/secrets/index.d.ts +55 -0
- package/dist/lib/secrets/index.js +211 -0
- package/dist/lib/secrets/profiles.d.ts +10 -0
- package/dist/lib/secrets/profiles.js +13 -0
- package/dist/lib/session/active.d.ts +43 -0
- package/dist/lib/session/active.js +392 -0
- package/dist/lib/session/artifacts.d.ts +16 -0
- package/dist/lib/session/artifacts.js +95 -0
- package/dist/lib/session/cloud.d.ts +30 -0
- package/dist/lib/session/cloud.js +121 -0
- package/dist/lib/session/db.d.ts +23 -2
- package/dist/lib/session/db.js +76 -12
- package/dist/lib/session/discover.d.ts +19 -4
- package/dist/lib/session/discover.js +344 -48
- package/dist/lib/session/parse.d.ts +28 -1
- package/dist/lib/session/parse.js +267 -9
- package/dist/lib/session/prompt.d.ts +9 -1
- package/dist/lib/session/prompt.js +17 -3
- package/dist/lib/session/render.d.ts +13 -1
- package/dist/lib/session/render.js +20 -1
- package/dist/lib/session/team-filter.d.ts +9 -1
- package/dist/lib/session/team-filter.js +11 -2
- package/dist/lib/session/types.d.ts +24 -2
- package/dist/lib/session/types.js +10 -2
- package/dist/lib/shims.d.ts +93 -5
- package/dist/lib/shims.js +380 -67
- package/dist/lib/skills.d.ts +27 -2
- package/dist/lib/skills.js +127 -65
- package/dist/lib/sqlite.d.ts +43 -0
- package/dist/lib/sqlite.js +94 -0
- package/dist/lib/state.d.ts +114 -22
- package/dist/lib/state.js +323 -138
- package/dist/lib/subagents.d.ts +9 -1
- package/dist/lib/subagents.js +70 -63
- package/dist/lib/sync-manifest.d.ts +81 -0
- package/dist/lib/sync-manifest.js +450 -0
- package/dist/lib/teams/agents.d.ts +103 -5
- package/dist/lib/teams/agents.js +414 -91
- package/dist/lib/teams/api.d.ts +26 -3
- package/dist/lib/teams/api.js +63 -3
- package/dist/lib/teams/debug.d.ts +6 -1
- package/dist/lib/teams/debug.js +6 -1
- package/dist/lib/teams/file_ops.d.ts +7 -1
- package/dist/lib/teams/file_ops.js +7 -1
- package/dist/lib/teams/index.d.ts +15 -0
- package/dist/lib/teams/index.js +14 -0
- package/dist/lib/teams/parsers.d.ts +4 -1
- package/dist/lib/teams/parsers.js +11 -1
- package/dist/lib/teams/persistence.d.ts +15 -1
- package/dist/lib/teams/persistence.js +102 -20
- package/dist/lib/teams/registry.d.ts +12 -1
- package/dist/lib/teams/registry.js +116 -33
- package/dist/lib/teams/summarizer.d.ts +15 -1
- package/dist/lib/teams/summarizer.js +14 -1
- package/dist/lib/teams/supervisor.d.ts +48 -0
- package/dist/lib/teams/supervisor.js +73 -0
- package/dist/lib/template.d.ts +8 -6
- package/dist/lib/template.js +8 -6
- package/dist/lib/types.d.ts +147 -8
- package/dist/lib/types.js +26 -3
- package/dist/lib/usage.d.ts +48 -1
- package/dist/lib/usage.js +97 -16
- package/dist/lib/version-duplicates.d.ts +21 -0
- package/dist/lib/version-duplicates.js +90 -0
- package/dist/lib/versions.d.ts +39 -4
- package/dist/lib/versions.js +401 -111
- package/package.json +33 -18
- package/scripts/postinstall.js +126 -30
- package/dist/commands/__tests__/sessions.test.d.ts +0 -2
- package/dist/commands/__tests__/sessions.test.d.ts.map +0 -1
- package/dist/commands/__tests__/sessions.test.js +0 -636
- package/dist/commands/__tests__/sessions.test.js.map +0 -1
- package/dist/commands/commands.d.ts.map +0 -1
- package/dist/commands/commands.js.map +0 -1
- package/dist/commands/daemon.d.ts.map +0 -1
- package/dist/commands/daemon.js.map +0 -1
- package/dist/commands/drive.d.ts.map +0 -1
- package/dist/commands/drive.js.map +0 -1
- package/dist/commands/exec.d.ts.map +0 -1
- package/dist/commands/exec.js.map +0 -1
- package/dist/commands/fork.d.ts.map +0 -1
- package/dist/commands/fork.js.map +0 -1
- package/dist/commands/hooks.d.ts.map +0 -1
- package/dist/commands/hooks.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/mcp.d.ts.map +0 -1
- package/dist/commands/mcp.js.map +0 -1
- package/dist/commands/models.d.ts.map +0 -1
- package/dist/commands/models.js.map +0 -1
- package/dist/commands/packages.d.ts.map +0 -1
- package/dist/commands/packages.js.map +0 -1
- package/dist/commands/permissions.d.ts.map +0 -1
- package/dist/commands/permissions.js.map +0 -1
- package/dist/commands/plugins.d.ts.map +0 -1
- package/dist/commands/plugins.js.map +0 -1
- package/dist/commands/pty.d.ts.map +0 -1
- package/dist/commands/pty.js.map +0 -1
- package/dist/commands/pull.d.ts.map +0 -1
- package/dist/commands/pull.js.map +0 -1
- package/dist/commands/push.d.ts +0 -3
- package/dist/commands/push.d.ts.map +0 -1
- package/dist/commands/push.js +0 -180
- package/dist/commands/push.js.map +0 -1
- package/dist/commands/refresh-memory.d.ts.map +0 -1
- package/dist/commands/refresh-memory.js.map +0 -1
- package/dist/commands/resource-view.d.ts.map +0 -1
- package/dist/commands/resource-view.js.map +0 -1
- package/dist/commands/routines.d.ts.map +0 -1
- package/dist/commands/routines.js.map +0 -1
- package/dist/commands/rules.d.ts.map +0 -1
- package/dist/commands/rules.js.map +0 -1
- package/dist/commands/sessions-picker.d.ts.map +0 -1
- package/dist/commands/sessions-picker.js.map +0 -1
- package/dist/commands/sessions.d.ts.map +0 -1
- package/dist/commands/sessions.js.map +0 -1
- package/dist/commands/skills.d.ts.map +0 -1
- package/dist/commands/skills.js.map +0 -1
- package/dist/commands/status.d.ts.map +0 -1
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/subagents.d.ts.map +0 -1
- package/dist/commands/subagents.js.map +0 -1
- package/dist/commands/sync.d.ts.map +0 -1
- package/dist/commands/sync.js.map +0 -1
- package/dist/commands/teams-picker.d.ts.map +0 -1
- package/dist/commands/teams-picker.js.map +0 -1
- package/dist/commands/teams.d.ts.map +0 -1
- package/dist/commands/teams.js.map +0 -1
- package/dist/commands/utils.d.ts.map +0 -1
- package/dist/commands/utils.js.map +0 -1
- package/dist/commands/versions.d.ts.map +0 -1
- package/dist/commands/versions.js.map +0 -1
- package/dist/commands/view.d.ts.map +0 -1
- package/dist/commands/view.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/__tests__/bugfixes.test.d.ts +0 -2
- package/dist/lib/__tests__/bugfixes.test.d.ts.map +0 -1
- package/dist/lib/__tests__/bugfixes.test.js +0 -192
- package/dist/lib/__tests__/bugfixes.test.js.map +0 -1
- package/dist/lib/__tests__/exec.test.d.ts +0 -2
- package/dist/lib/__tests__/exec.test.d.ts.map +0 -1
- package/dist/lib/__tests__/exec.test.js +0 -446
- package/dist/lib/__tests__/exec.test.js.map +0 -1
- package/dist/lib/__tests__/git-sync.test.d.ts +0 -2
- package/dist/lib/__tests__/git-sync.test.d.ts.map +0 -1
- package/dist/lib/__tests__/git-sync.test.js +0 -138
- package/dist/lib/__tests__/git-sync.test.js.map +0 -1
- package/dist/lib/__tests__/hooks.test.d.ts +0 -2
- package/dist/lib/__tests__/hooks.test.d.ts.map +0 -1
- package/dist/lib/__tests__/hooks.test.js +0 -203
- package/dist/lib/__tests__/hooks.test.js.map +0 -1
- package/dist/lib/__tests__/memory-compile.test.d.ts +0 -2
- package/dist/lib/__tests__/memory-compile.test.d.ts.map +0 -1
- package/dist/lib/__tests__/memory-compile.test.js +0 -95
- package/dist/lib/__tests__/memory-compile.test.js.map +0 -1
- package/dist/lib/__tests__/models.test.d.ts +0 -2
- package/dist/lib/__tests__/models.test.d.ts.map +0 -1
- package/dist/lib/__tests__/models.test.js +0 -184
- package/dist/lib/__tests__/models.test.js.map +0 -1
- package/dist/lib/__tests__/usage.test.d.ts +0 -2
- package/dist/lib/__tests__/usage.test.d.ts.map +0 -1
- package/dist/lib/__tests__/usage.test.js +0 -218
- package/dist/lib/__tests__/usage.test.js.map +0 -1
- package/dist/lib/agents.d.ts.map +0 -1
- package/dist/lib/agents.js.map +0 -1
- package/dist/lib/artifact-actions.d.ts.map +0 -1
- package/dist/lib/artifact-actions.js.map +0 -1
- package/dist/lib/commands.d.ts.map +0 -1
- package/dist/lib/commands.js.map +0 -1
- package/dist/lib/convert.d.ts.map +0 -1
- package/dist/lib/convert.js.map +0 -1
- package/dist/lib/daemon.d.ts.map +0 -1
- package/dist/lib/daemon.js.map +0 -1
- package/dist/lib/drive-sync.d.ts.map +0 -1
- package/dist/lib/drive-sync.js.map +0 -1
- package/dist/lib/exec.d.ts.map +0 -1
- package/dist/lib/exec.js.map +0 -1
- package/dist/lib/factory.d.ts +0 -57
- package/dist/lib/factory.d.ts.map +0 -1
- package/dist/lib/factory.js +0 -110
- package/dist/lib/factory.js.map +0 -1
- package/dist/lib/git.d.ts.map +0 -1
- package/dist/lib/git.js.map +0 -1
- package/dist/lib/help.d.ts.map +0 -1
- package/dist/lib/help.js.map +0 -1
- package/dist/lib/hooks.d.ts.map +0 -1
- package/dist/lib/hooks.js.map +0 -1
- package/dist/lib/manifest.d.ts.map +0 -1
- package/dist/lib/manifest.js.map +0 -1
- package/dist/lib/markdown.d.ts.map +0 -1
- package/dist/lib/markdown.js.map +0 -1
- package/dist/lib/mcp.d.ts.map +0 -1
- package/dist/lib/mcp.js.map +0 -1
- package/dist/lib/memory-compile.d.ts.map +0 -1
- package/dist/lib/memory-compile.js.map +0 -1
- package/dist/lib/memory.d.ts.map +0 -1
- package/dist/lib/memory.js.map +0 -1
- package/dist/lib/models.d.ts.map +0 -1
- package/dist/lib/models.js.map +0 -1
- package/dist/lib/permissions.d.ts.map +0 -1
- package/dist/lib/permissions.js.map +0 -1
- package/dist/lib/picker.d.ts.map +0 -1
- package/dist/lib/picker.js.map +0 -1
- package/dist/lib/plugins.d.ts.map +0 -1
- package/dist/lib/plugins.js.map +0 -1
- package/dist/lib/pty-client.d.ts.map +0 -1
- package/dist/lib/pty-client.js.map +0 -1
- package/dist/lib/pty-server.d.ts.map +0 -1
- package/dist/lib/pty-server.js.map +0 -1
- package/dist/lib/registry.d.ts.map +0 -1
- package/dist/lib/registry.js.map +0 -1
- package/dist/lib/resources.d.ts.map +0 -1
- package/dist/lib/resources.js.map +0 -1
- package/dist/lib/routines.d.ts.map +0 -1
- package/dist/lib/routines.js.map +0 -1
- package/dist/lib/runner.d.ts.map +0 -1
- package/dist/lib/runner.js.map +0 -1
- package/dist/lib/sandbox.d.ts.map +0 -1
- package/dist/lib/sandbox.js.map +0 -1
- package/dist/lib/scheduler.d.ts.map +0 -1
- package/dist/lib/scheduler.js.map +0 -1
- package/dist/lib/session/__tests__/db.test.d.ts +0 -2
- package/dist/lib/session/__tests__/db.test.d.ts.map +0 -1
- package/dist/lib/session/__tests__/db.test.js +0 -54
- package/dist/lib/session/__tests__/db.test.js.map +0 -1
- package/dist/lib/session/__tests__/discover.test.d.ts +0 -2
- package/dist/lib/session/__tests__/discover.test.d.ts.map +0 -1
- package/dist/lib/session/__tests__/discover.test.js +0 -63
- package/dist/lib/session/__tests__/discover.test.js.map +0 -1
- package/dist/lib/session/__tests__/prompt.test.d.ts +0 -2
- package/dist/lib/session/__tests__/prompt.test.d.ts.map +0 -1
- package/dist/lib/session/__tests__/prompt.test.js +0 -44
- package/dist/lib/session/__tests__/prompt.test.js.map +0 -1
- package/dist/lib/session/__tests__/render.test.d.ts +0 -2
- package/dist/lib/session/__tests__/render.test.d.ts.map +0 -1
- package/dist/lib/session/__tests__/render.test.js +0 -602
- package/dist/lib/session/__tests__/render.test.js.map +0 -1
- package/dist/lib/session/db.d.ts.map +0 -1
- package/dist/lib/session/db.js.map +0 -1
- package/dist/lib/session/discover.d.ts.map +0 -1
- package/dist/lib/session/discover.js.map +0 -1
- package/dist/lib/session/parse.d.ts.map +0 -1
- package/dist/lib/session/parse.js.map +0 -1
- package/dist/lib/session/prompt.d.ts.map +0 -1
- package/dist/lib/session/prompt.js.map +0 -1
- package/dist/lib/session/prompt.test.d.ts +0 -2
- package/dist/lib/session/prompt.test.d.ts.map +0 -1
- package/dist/lib/session/prompt.test.js +0 -57
- package/dist/lib/session/prompt.test.js.map +0 -1
- package/dist/lib/session/render.d.ts.map +0 -1
- package/dist/lib/session/render.js.map +0 -1
- package/dist/lib/session/team-filter.d.ts.map +0 -1
- package/dist/lib/session/team-filter.js.map +0 -1
- package/dist/lib/session/team-filter.test.d.ts +0 -2
- package/dist/lib/session/team-filter.test.d.ts.map +0 -1
- package/dist/lib/session/team-filter.test.js +0 -157
- package/dist/lib/session/team-filter.test.js.map +0 -1
- package/dist/lib/session/types.d.ts.map +0 -1
- package/dist/lib/session/types.js.map +0 -1
- package/dist/lib/shims.d.ts.map +0 -1
- package/dist/lib/shims.js.map +0 -1
- package/dist/lib/skills.d.ts.map +0 -1
- package/dist/lib/skills.js.map +0 -1
- package/dist/lib/state.d.ts.map +0 -1
- package/dist/lib/state.js.map +0 -1
- package/dist/lib/subagents.d.ts.map +0 -1
- package/dist/lib/subagents.js.map +0 -1
- package/dist/lib/teams/agents.d.ts.map +0 -1
- package/dist/lib/teams/agents.js.map +0 -1
- package/dist/lib/teams/api.d.ts.map +0 -1
- package/dist/lib/teams/api.js.map +0 -1
- package/dist/lib/teams/cloud.d.ts +0 -11
- package/dist/lib/teams/cloud.d.ts.map +0 -1
- package/dist/lib/teams/cloud.js +0 -169
- package/dist/lib/teams/cloud.js.map +0 -1
- package/dist/lib/teams/debug.d.ts.map +0 -1
- package/dist/lib/teams/debug.js.map +0 -1
- package/dist/lib/teams/file_ops.d.ts.map +0 -1
- package/dist/lib/teams/file_ops.js.map +0 -1
- package/dist/lib/teams/parsers.d.ts.map +0 -1
- package/dist/lib/teams/parsers.js.map +0 -1
- package/dist/lib/teams/persistence.d.ts.map +0 -1
- package/dist/lib/teams/persistence.js.map +0 -1
- package/dist/lib/teams/ralph.d.ts +0 -8
- package/dist/lib/teams/ralph.d.ts.map +0 -1
- package/dist/lib/teams/ralph.js +0 -59
- package/dist/lib/teams/ralph.js.map +0 -1
- package/dist/lib/teams/registry.d.ts.map +0 -1
- package/dist/lib/teams/registry.js.map +0 -1
- package/dist/lib/teams/summarizer.d.ts.map +0 -1
- package/dist/lib/teams/summarizer.js.map +0 -1
- package/dist/lib/template.d.ts.map +0 -1
- package/dist/lib/template.js.map +0 -1
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/usage.d.ts.map +0 -1
- package/dist/lib/usage.js.map +0 -1
- package/dist/lib/versions.d.ts.map +0 -1
- package/dist/lib/versions.js.map +0 -1
- package/scripts/rebuild-sqlite.sh +0 -46
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync manifest — fast staleness guard for syncResourcesToVersion.
|
|
3
|
+
*
|
|
4
|
+
* Written after each full sync; read before the next to skip unconditional
|
|
5
|
+
* re-copies when nothing has changed. Two-tier check:
|
|
6
|
+
* Tier 1 — stat mtime+size ~0.01ms/file (kernel VFS cache)
|
|
7
|
+
* Tier 2 — sha256 on miss ~0.1–0.5ms/file
|
|
8
|
+
*
|
|
9
|
+
* Env vars in MCP YAML are NOT substituted by agents-cli — ${VAR} is stored
|
|
10
|
+
* verbatim and passed as-is to `claude mcp add`. Value-only env var changes
|
|
11
|
+
* (YAML content unchanged) are not detected and are not in scope.
|
|
12
|
+
*
|
|
13
|
+
* Layering model:
|
|
14
|
+
* First-wins (commands, skills, hooks, MCP, rules): manifest stores fingerprint
|
|
15
|
+
* of the WINNING source (project > user > system > extra). A scope change
|
|
16
|
+
* (e.g. project file added/removed) is detected via resolved-path mismatch.
|
|
17
|
+
*
|
|
18
|
+
* Merged (permissions): all group files across all scopes contribute. Any
|
|
19
|
+
* change in any scope file triggers re-sync.
|
|
20
|
+
*
|
|
21
|
+
* The manifest is written only after a full (unselected) sync and is only used
|
|
22
|
+
* as a guard for full syncs — partial/interactive syncs bypass it entirely.
|
|
23
|
+
*/
|
|
24
|
+
import * as fs from 'fs';
|
|
25
|
+
import * as path from 'path';
|
|
26
|
+
import * as crypto from 'crypto';
|
|
27
|
+
import { getVersionsDir, getProjectAgentsDir, getUserAgentsDir, getSkillsDir, getUserHooksDir, getHooksDir, getUserRulesDir, getResolvedRulesDir, getUserPermissionsDir, getPermissionsDir, getEnabledExtraRepos, } from './state.js';
|
|
28
|
+
import { resolveResource } from './resources.js';
|
|
29
|
+
import { listMcpServerConfigs } from './mcp.js';
|
|
30
|
+
import { isMemoryStale } from './memory-compile.js';
|
|
31
|
+
import { getActivePermissionSetName } from './permissions.js';
|
|
32
|
+
import { listInstalledSubagents } from './subagents.js';
|
|
33
|
+
import { safeJoin } from './paths.js';
|
|
34
|
+
// ─── Types ────────────────────────────────────────────────────────────────────
|
|
35
|
+
const MANIFEST_VERSION = 1;
|
|
36
|
+
// ─── Path helpers ─────────────────────────────────────────────────────────────
|
|
37
|
+
function manifestPath(agent, version) {
|
|
38
|
+
return path.join(getVersionsDir(), agent, version, 'home', '.sync-manifest.json');
|
|
39
|
+
}
|
|
40
|
+
// ─── Fingerprinting ───────────────────────────────────────────────────────────
|
|
41
|
+
function sha256(content) {
|
|
42
|
+
return crypto.createHash('sha256').update(content).digest('hex');
|
|
43
|
+
}
|
|
44
|
+
/** Compute fingerprint for a single file. Returns null if the file can't be read. */
|
|
45
|
+
function fingerprintFile(filePath) {
|
|
46
|
+
try {
|
|
47
|
+
const stat = fs.statSync(filePath);
|
|
48
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
49
|
+
return {
|
|
50
|
+
path: filePath,
|
|
51
|
+
mtime: stat.mtimeMs,
|
|
52
|
+
size: stat.size,
|
|
53
|
+
sha256: sha256(content),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Fingerprint all files in a directory recursively.
|
|
62
|
+
* Returns sorted by absolute path so ordering is deterministic.
|
|
63
|
+
*/
|
|
64
|
+
function fingerprintDir(dirPath) {
|
|
65
|
+
const results = [];
|
|
66
|
+
function walk(dir) {
|
|
67
|
+
let entries;
|
|
68
|
+
try {
|
|
69
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
for (const entry of entries) {
|
|
75
|
+
if (entry.name.startsWith('.'))
|
|
76
|
+
continue;
|
|
77
|
+
const full = path.join(dir, entry.name);
|
|
78
|
+
if (entry.isDirectory()) {
|
|
79
|
+
walk(full);
|
|
80
|
+
}
|
|
81
|
+
else if (entry.isFile()) {
|
|
82
|
+
const fp = fingerprintFile(full);
|
|
83
|
+
if (fp)
|
|
84
|
+
results.push(fp);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
walk(dirPath);
|
|
89
|
+
results.sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
|
|
90
|
+
return results;
|
|
91
|
+
}
|
|
92
|
+
// ─── Staleness check ──────────────────────────────────────────────────────────
|
|
93
|
+
/**
|
|
94
|
+
* Check if a stored fingerprint is still valid for the file at its recorded path.
|
|
95
|
+
* Tier 1: mtime+size match → clean (no read needed).
|
|
96
|
+
* Tier 2: sha256 match → clean (mtime drifted, content same).
|
|
97
|
+
* Path mismatch → immediately stale (scope changed).
|
|
98
|
+
*/
|
|
99
|
+
function isFileStale(stored, currentPath) {
|
|
100
|
+
if (stored.path !== currentPath)
|
|
101
|
+
return true;
|
|
102
|
+
try {
|
|
103
|
+
const stat = fs.statSync(currentPath);
|
|
104
|
+
if (stat.mtimeMs === stored.mtime && stat.size === stored.size)
|
|
105
|
+
return false;
|
|
106
|
+
return sha256(fs.readFileSync(currentPath, 'utf-8')) !== stored.sha256;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return true; // file disappeared
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Walk a directory recursively and return sorted absolute file paths.
|
|
114
|
+
* No file reads — used for the hot-path check where we want stat-only speed.
|
|
115
|
+
*/
|
|
116
|
+
function walkDirPaths(dirPath) {
|
|
117
|
+
const results = [];
|
|
118
|
+
function walk(dir) {
|
|
119
|
+
let entries;
|
|
120
|
+
try {
|
|
121
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
for (const entry of entries) {
|
|
127
|
+
if (entry.name.startsWith('.'))
|
|
128
|
+
continue;
|
|
129
|
+
const full = path.join(dir, entry.name);
|
|
130
|
+
if (entry.isDirectory()) {
|
|
131
|
+
walk(full);
|
|
132
|
+
}
|
|
133
|
+
else if (entry.isFile()) {
|
|
134
|
+
results.push(full);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
walk(dirPath);
|
|
139
|
+
results.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
140
|
+
return results;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Check if a DirEntry is stale for the given source directory.
|
|
144
|
+
* Hot path: stat only (no file reads) when mtime+size match.
|
|
145
|
+
*/
|
|
146
|
+
function isDirStale(stored, currentDirPath) {
|
|
147
|
+
if (stored.dirPath !== currentDirPath)
|
|
148
|
+
return true;
|
|
149
|
+
// Get current file list without reading content
|
|
150
|
+
const currentPaths = walkDirPaths(currentDirPath);
|
|
151
|
+
if (currentPaths.length !== stored.files.length)
|
|
152
|
+
return true;
|
|
153
|
+
for (let i = 0; i < currentPaths.length; i++) {
|
|
154
|
+
const storedFp = stored.files[i];
|
|
155
|
+
const currentPath = currentPaths[i];
|
|
156
|
+
if (storedFp.path !== currentPath)
|
|
157
|
+
return true; // added/removed/renamed
|
|
158
|
+
// Tier 1: mtime+size stat only
|
|
159
|
+
try {
|
|
160
|
+
const stat = fs.statSync(currentPath);
|
|
161
|
+
if (stat.mtimeMs === storedFp.mtime && stat.size === storedFp.size)
|
|
162
|
+
continue;
|
|
163
|
+
// Tier 2: sha256 (only on mismatch)
|
|
164
|
+
if (sha256(fs.readFileSync(currentPath, 'utf-8')) !== storedFp.sha256)
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
/** Compare sorted name sets. Returns true if they differ. */
|
|
174
|
+
function nameSetDiffers(manifestKeys, available) {
|
|
175
|
+
if (manifestKeys.length !== available.length)
|
|
176
|
+
return true;
|
|
177
|
+
const sorted = [...available].sort();
|
|
178
|
+
const mSorted = [...manifestKeys].sort();
|
|
179
|
+
return sorted.some((name, i) => name !== mSorted[i]);
|
|
180
|
+
}
|
|
181
|
+
// ─── Source resolution helpers ────────────────────────────────────────────────
|
|
182
|
+
function resolveSkillDir(skill, cwd) {
|
|
183
|
+
const projectDir = getProjectAgentsDir(cwd);
|
|
184
|
+
const candidates = [
|
|
185
|
+
projectDir ? path.join(projectDir, 'skills', skill) : null,
|
|
186
|
+
path.join(getUserAgentsDir(), 'skills', skill),
|
|
187
|
+
path.join(getSkillsDir(), skill),
|
|
188
|
+
...getEnabledExtraRepos().map(e => path.join(e.dir, 'skills', skill)),
|
|
189
|
+
];
|
|
190
|
+
return candidates.find(p => p && fs.existsSync(p) && fs.statSync(p).isDirectory()) ?? null;
|
|
191
|
+
}
|
|
192
|
+
function resolveRuleFile(mem, cwd) {
|
|
193
|
+
const projectDir = getProjectAgentsDir(cwd);
|
|
194
|
+
const candidates = [
|
|
195
|
+
projectDir ? safeJoin(path.join(projectDir, 'rules'), `${mem}.md`) : null,
|
|
196
|
+
safeJoin(getUserRulesDir(), `${mem}.md`),
|
|
197
|
+
safeJoin(getResolvedRulesDir(), `${mem}.md`),
|
|
198
|
+
...getEnabledExtraRepos().map(e => safeJoin(path.join(e.dir, 'rules'), `${mem}.md`)),
|
|
199
|
+
];
|
|
200
|
+
return candidates.find(p => {
|
|
201
|
+
if (!p)
|
|
202
|
+
return false;
|
|
203
|
+
try {
|
|
204
|
+
return !fs.lstatSync(p).isSymbolicLink() && fs.existsSync(p);
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
}) ?? null;
|
|
210
|
+
}
|
|
211
|
+
/** Collect all permission group files across all scopes (first-wins per name). */
|
|
212
|
+
function collectPermissionGroupFiles() {
|
|
213
|
+
const seen = new Map(); // name → filePath (first-wins: user > system)
|
|
214
|
+
for (const baseDir of [getUserPermissionsDir(), getPermissionsDir()]) {
|
|
215
|
+
const groupsDir = path.join(baseDir, 'groups');
|
|
216
|
+
if (!fs.existsSync(groupsDir))
|
|
217
|
+
continue;
|
|
218
|
+
let entries;
|
|
219
|
+
try {
|
|
220
|
+
entries = fs.readdirSync(groupsDir, { withFileTypes: true });
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
for (const entry of entries) {
|
|
226
|
+
if (!entry.isFile())
|
|
227
|
+
continue;
|
|
228
|
+
if (!entry.name.endsWith('.yaml') && !entry.name.endsWith('.yml'))
|
|
229
|
+
continue;
|
|
230
|
+
const name = entry.name.replace(/\.(yaml|yml)$/, '');
|
|
231
|
+
if (!seen.has(name))
|
|
232
|
+
seen.set(name, path.join(groupsDir, entry.name));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return Object.fromEntries(seen);
|
|
236
|
+
}
|
|
237
|
+
// ─── Public API ───────────────────────────────────────────────────────────────
|
|
238
|
+
/** Load the manifest for a given agent+version. Returns null on miss or parse error. */
|
|
239
|
+
export function loadSyncManifest(agent, version) {
|
|
240
|
+
const p = manifestPath(agent, version);
|
|
241
|
+
try {
|
|
242
|
+
const raw = JSON.parse(fs.readFileSync(p, 'utf-8'));
|
|
243
|
+
if (raw.v !== MANIFEST_VERSION)
|
|
244
|
+
return null;
|
|
245
|
+
return raw;
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/** Write the manifest atomically (tmp + rename). */
|
|
252
|
+
export function saveSyncManifest(agent, version, manifest) {
|
|
253
|
+
const p = manifestPath(agent, version);
|
|
254
|
+
const tmp = p + '.tmp';
|
|
255
|
+
try {
|
|
256
|
+
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
257
|
+
fs.writeFileSync(tmp, JSON.stringify(manifest, null, 2));
|
|
258
|
+
fs.renameSync(tmp, p);
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
try {
|
|
262
|
+
fs.unlinkSync(tmp);
|
|
263
|
+
}
|
|
264
|
+
catch { /* ignore */ }
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Build a manifest by fingerprinting current source state.
|
|
269
|
+
* Call this after a successful full sync.
|
|
270
|
+
*/
|
|
271
|
+
export function buildManifest(agent, version, available, cwd) {
|
|
272
|
+
const commands = {};
|
|
273
|
+
for (const name of available.commands) {
|
|
274
|
+
const resolved = resolveResource('commands', `${name}.md`, cwd);
|
|
275
|
+
if (!resolved)
|
|
276
|
+
continue;
|
|
277
|
+
const fp = fingerprintFile(resolved.path);
|
|
278
|
+
if (fp)
|
|
279
|
+
commands[name] = { source: fp };
|
|
280
|
+
}
|
|
281
|
+
const skills = {};
|
|
282
|
+
for (const name of available.skills) {
|
|
283
|
+
const dirPath = resolveSkillDir(name, cwd);
|
|
284
|
+
if (!dirPath)
|
|
285
|
+
continue;
|
|
286
|
+
skills[name] = { dirPath, files: fingerprintDir(dirPath) };
|
|
287
|
+
}
|
|
288
|
+
const hooks = {};
|
|
289
|
+
for (const name of available.hooks) {
|
|
290
|
+
// Hooks: resolve winning source manually (project > user > system > extra)
|
|
291
|
+
const projectDir = getProjectAgentsDir(cwd);
|
|
292
|
+
const candidates = [
|
|
293
|
+
projectDir ? path.join(projectDir, 'hooks', name) : null,
|
|
294
|
+
path.join(getUserHooksDir(), name),
|
|
295
|
+
path.join(getHooksDir(), name),
|
|
296
|
+
...getEnabledExtraRepos().map(e => path.join(e.dir, 'hooks', name)),
|
|
297
|
+
];
|
|
298
|
+
const hookPath = candidates.find(p => p && fs.existsSync(p)) ?? null;
|
|
299
|
+
if (!hookPath)
|
|
300
|
+
continue;
|
|
301
|
+
const fp = fingerprintFile(hookPath);
|
|
302
|
+
if (fp)
|
|
303
|
+
hooks[name] = { source: fp };
|
|
304
|
+
}
|
|
305
|
+
const ruleFiles = {};
|
|
306
|
+
for (const name of available.memory) {
|
|
307
|
+
const srcPath = resolveRuleFile(name, cwd);
|
|
308
|
+
if (!srcPath)
|
|
309
|
+
continue;
|
|
310
|
+
const fp = fingerprintFile(srcPath);
|
|
311
|
+
if (fp)
|
|
312
|
+
ruleFiles[name] = { source: fp };
|
|
313
|
+
}
|
|
314
|
+
const mcp = {};
|
|
315
|
+
for (const server of listMcpServerConfigs(cwd)) {
|
|
316
|
+
const fp = fingerprintFile(server.path);
|
|
317
|
+
if (fp)
|
|
318
|
+
mcp[server.name] = { source: fp };
|
|
319
|
+
}
|
|
320
|
+
const groupFiles = collectPermissionGroupFiles();
|
|
321
|
+
const permGroups = {};
|
|
322
|
+
for (const [name, filePath] of Object.entries(groupFiles)) {
|
|
323
|
+
const fp = fingerprintFile(filePath);
|
|
324
|
+
if (fp)
|
|
325
|
+
permGroups[name] = { source: fp };
|
|
326
|
+
}
|
|
327
|
+
// Subagents: user > system, first-wins per name (mirrors listInstalledSubagents())
|
|
328
|
+
const subagents = {};
|
|
329
|
+
for (const sub of listInstalledSubagents()) {
|
|
330
|
+
if (!available.subagents.includes(sub.name))
|
|
331
|
+
continue;
|
|
332
|
+
subagents[sub.name] = { dirPath: sub.path, files: fingerprintDir(sub.path) };
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
v: MANIFEST_VERSION,
|
|
336
|
+
syncedAt: new Date().toISOString(),
|
|
337
|
+
commands,
|
|
338
|
+
skills,
|
|
339
|
+
hooks,
|
|
340
|
+
rules: { files: ruleFiles },
|
|
341
|
+
mcp,
|
|
342
|
+
permissions: {
|
|
343
|
+
groups: permGroups,
|
|
344
|
+
permissionSet: getActivePermissionSetName(),
|
|
345
|
+
},
|
|
346
|
+
subagents,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Check if sources have changed since the manifest was written.
|
|
351
|
+
* Returns true (stale) at the first detected mismatch — no need to scan everything.
|
|
352
|
+
* Returns false (clean) only after all checks pass.
|
|
353
|
+
*
|
|
354
|
+
* For rules, also delegates to isMemoryStale() to catch @-import changes
|
|
355
|
+
* for agents that pre-compile their memory file.
|
|
356
|
+
*/
|
|
357
|
+
export function isSyncStale(manifest, available, agent, version, cwd) {
|
|
358
|
+
// ── Commands ──────────────────────────────────────────────────────────────
|
|
359
|
+
if (nameSetDiffers(Object.keys(manifest.commands), available.commands))
|
|
360
|
+
return true;
|
|
361
|
+
for (const name of available.commands) {
|
|
362
|
+
const resolved = resolveResource('commands', `${name}.md`, cwd);
|
|
363
|
+
if (!resolved)
|
|
364
|
+
return true;
|
|
365
|
+
const entry = manifest.commands[name];
|
|
366
|
+
if (!entry || isFileStale(entry.source, resolved.path))
|
|
367
|
+
return true;
|
|
368
|
+
}
|
|
369
|
+
// ── Skills ────────────────────────────────────────────────────────────────
|
|
370
|
+
if (nameSetDiffers(Object.keys(manifest.skills), available.skills))
|
|
371
|
+
return true;
|
|
372
|
+
for (const name of available.skills) {
|
|
373
|
+
const dirPath = resolveSkillDir(name, cwd);
|
|
374
|
+
if (!dirPath)
|
|
375
|
+
return true;
|
|
376
|
+
const entry = manifest.skills[name];
|
|
377
|
+
if (!entry || isDirStale(entry, dirPath))
|
|
378
|
+
return true;
|
|
379
|
+
}
|
|
380
|
+
// ── Hooks ─────────────────────────────────────────────────────────────────
|
|
381
|
+
if (nameSetDiffers(Object.keys(manifest.hooks), available.hooks))
|
|
382
|
+
return true;
|
|
383
|
+
for (const name of available.hooks) {
|
|
384
|
+
const projectDir = getProjectAgentsDir(cwd);
|
|
385
|
+
const candidates = [
|
|
386
|
+
projectDir ? path.join(projectDir, 'hooks', name) : null,
|
|
387
|
+
path.join(getUserHooksDir(), name),
|
|
388
|
+
path.join(getHooksDir(), name),
|
|
389
|
+
...getEnabledExtraRepos().map(e => path.join(e.dir, 'hooks', name)),
|
|
390
|
+
];
|
|
391
|
+
const hookPath = candidates.find(p => p && fs.existsSync(p)) ?? null;
|
|
392
|
+
if (!hookPath)
|
|
393
|
+
return true;
|
|
394
|
+
const entry = manifest.hooks[name];
|
|
395
|
+
if (!entry || isFileStale(entry.source, hookPath))
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
398
|
+
// ── Rules/memory ──────────────────────────────────────────────────────────
|
|
399
|
+
if (nameSetDiffers(Object.keys(manifest.rules.files), available.memory))
|
|
400
|
+
return true;
|
|
401
|
+
for (const name of available.memory) {
|
|
402
|
+
const srcPath = resolveRuleFile(name, cwd);
|
|
403
|
+
if (!srcPath)
|
|
404
|
+
return true;
|
|
405
|
+
const entry = manifest.rules.files[name];
|
|
406
|
+
if (!entry || isFileStale(entry.source, srcPath))
|
|
407
|
+
return true;
|
|
408
|
+
}
|
|
409
|
+
// Also catch @-import changes for non-native-import agents
|
|
410
|
+
if (isMemoryStale(agent, version))
|
|
411
|
+
return true;
|
|
412
|
+
// ── MCP ───────────────────────────────────────────────────────────────────
|
|
413
|
+
const mcpServers = listMcpServerConfigs(cwd);
|
|
414
|
+
const mcpNames = mcpServers.map(s => s.name);
|
|
415
|
+
if (nameSetDiffers(Object.keys(manifest.mcp), mcpNames))
|
|
416
|
+
return true;
|
|
417
|
+
for (const server of mcpServers) {
|
|
418
|
+
const entry = manifest.mcp[server.name];
|
|
419
|
+
if (!entry || isFileStale(entry.source, server.path))
|
|
420
|
+
return true;
|
|
421
|
+
}
|
|
422
|
+
// ── Permissions ───────────────────────────────────────────────────────────
|
|
423
|
+
if (manifest.permissions.permissionSet !== getActivePermissionSetName())
|
|
424
|
+
return true;
|
|
425
|
+
const currentGroups = collectPermissionGroupFiles();
|
|
426
|
+
if (nameSetDiffers(Object.keys(manifest.permissions.groups), Object.keys(currentGroups)))
|
|
427
|
+
return true;
|
|
428
|
+
for (const [name, filePath] of Object.entries(currentGroups)) {
|
|
429
|
+
const entry = manifest.permissions.groups[name];
|
|
430
|
+
if (!entry || isFileStale(entry.source, filePath))
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
433
|
+
// ── Subagents ─────────────────────────────────────────────────────────────
|
|
434
|
+
const storedSubagents = manifest.subagents ?? {};
|
|
435
|
+
if (nameSetDiffers(Object.keys(storedSubagents), available.subagents))
|
|
436
|
+
return true;
|
|
437
|
+
if (available.subagents.length > 0) {
|
|
438
|
+
const allSubagents = listInstalledSubagents();
|
|
439
|
+
const subagentMap = new Map(allSubagents.map(s => [s.name, s]));
|
|
440
|
+
for (const name of available.subagents) {
|
|
441
|
+
const sub = subagentMap.get(name);
|
|
442
|
+
if (!sub)
|
|
443
|
+
return true;
|
|
444
|
+
const entry = storedSubagents[name];
|
|
445
|
+
if (!entry || isDirStale(entry, sub.path))
|
|
446
|
+
return true;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
@@ -6,6 +6,7 @@ import { AgentType } from './parsers.js';
|
|
|
6
6
|
* Returns null if paths is empty or paths have no common ancestor (different roots).
|
|
7
7
|
*/
|
|
8
8
|
export declare function computePathLCA(paths: string[]): string | null;
|
|
9
|
+
/** Lifecycle status of a teammate process. */
|
|
9
10
|
export declare enum AgentStatus {
|
|
10
11
|
PENDING = "pending",// staged with unresolved --after deps
|
|
11
12
|
RUNNING = "running",
|
|
@@ -13,20 +14,62 @@ export declare enum AgentStatus {
|
|
|
13
14
|
FAILED = "failed",
|
|
14
15
|
STOPPED = "stopped"
|
|
15
16
|
}
|
|
17
|
+
/** Task type label for Software Factory workflows. Drives planner fan-out. Optional — teammates without a task_type work exactly as before. */
|
|
18
|
+
export type TaskType = 'plan' | 'implement' | 'test' | 'review' | 'bugfix' | 'docs';
|
|
19
|
+
export declare const VALID_TASK_TYPES: readonly TaskType[];
|
|
16
20
|
export type { AgentType } from './parsers.js';
|
|
21
|
+
/**
|
|
22
|
+
* Capture a stable identifier for a process at the moment it was started.
|
|
23
|
+
* Used to defeat PID reuse: a kill(pid, ...) is only safe when the process
|
|
24
|
+
* still occupies the PID we observed at spawn time. A bare kill(pid, 0)
|
|
25
|
+
* probe cannot tell whether the OS has recycled the slot to an unrelated
|
|
26
|
+
* process — combined with detached spawns and unref(), that's exactly how
|
|
27
|
+
* `agents teams stop` ends up SIGKILLing random process groups.
|
|
28
|
+
*
|
|
29
|
+
* Linux: field 22 of /proc/<pid>/stat (starttime in clock ticks since boot).
|
|
30
|
+
* macOS: output of `ps -o lstart= -p <pid>` (start time in human format).
|
|
31
|
+
* Returns null on any error so callers can skip the guard rather than crash.
|
|
32
|
+
*/
|
|
33
|
+
export declare function captureProcessStartTime(pid: number): string | null;
|
|
17
34
|
export declare const AGENT_COMMANDS: Record<AgentType, string[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Rewrite a plan-mode command into edit mode (writes inside cwd allowed,
|
|
37
|
+
* approval prompts may still appear). Pure function — exported for tests.
|
|
38
|
+
*/
|
|
39
|
+
export declare function applyEditMode(agentType: AgentType, cmd: string[]): string[];
|
|
40
|
+
/**
|
|
41
|
+
* Rewrite a plan-mode command into full mode (writes + approval gates
|
|
42
|
+
* bypassed). Pure function — exported for tests.
|
|
43
|
+
*/
|
|
44
|
+
export declare function applyFullMode(agentType: AgentType, cmd: string[]): string[];
|
|
45
|
+
/**
|
|
46
|
+
* Reasoning-intensity knob wired into buildReasoningFlags.
|
|
47
|
+
* Does not select a model; use --model separately to pin a specific model per teammate.
|
|
48
|
+
*/
|
|
18
49
|
export type EffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'auto';
|
|
19
50
|
declare const VALID_MODES: readonly ["plan", "edit", "full"];
|
|
20
51
|
type Mode = typeof VALID_MODES[number];
|
|
52
|
+
/** Resolve a mode string to a validated Mode, falling back to the given default. */
|
|
21
53
|
export declare function resolveMode(requestedMode: string | null | undefined, defaultMode?: Mode): Mode;
|
|
54
|
+
/** Ensure Gemini's settings.json has experimental.plan enabled for headless plan mode. */
|
|
22
55
|
export declare function ensureGeminiPlanMode(): Promise<void>;
|
|
56
|
+
/** Check whether the CLI binary for a given agent type exists in PATH. Returns [available, pathOrError]. */
|
|
23
57
|
export declare function checkCliAvailable(agentType: AgentType): [boolean, string | null];
|
|
58
|
+
/** Check availability of all known agent CLIs. Returns a map of agent type to install status. */
|
|
24
59
|
export declare function checkAllClis(): Record<string, {
|
|
25
60
|
installed: boolean;
|
|
26
61
|
path: string | null;
|
|
27
62
|
error: string | null;
|
|
28
63
|
}>;
|
|
64
|
+
/** Resolve and cache the base directory where teammate process data is stored. */
|
|
29
65
|
export declare function getAgentsDir(): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Represents a single teammate process within a team.
|
|
68
|
+
*
|
|
69
|
+
* Tracks process metadata (PID, status, timestamps), reads incremental
|
|
70
|
+
* stdout events, persists state to disk as meta.json, and can be
|
|
71
|
+
* reconstituted from disk via loadFromDisk().
|
|
72
|
+
*/
|
|
30
73
|
export declare class AgentProcess {
|
|
31
74
|
agentId: string;
|
|
32
75
|
taskName: string;
|
|
@@ -36,6 +79,7 @@ export declare class AgentProcess {
|
|
|
36
79
|
workspaceDir: string | null;
|
|
37
80
|
mode: Mode;
|
|
38
81
|
pid: number | null;
|
|
82
|
+
startTime: string | null;
|
|
39
83
|
status: AgentStatus;
|
|
40
84
|
startedAt: Date;
|
|
41
85
|
completedAt: Date | null;
|
|
@@ -50,12 +94,36 @@ export declare class AgentProcess {
|
|
|
50
94
|
effort: EffortLevel | null;
|
|
51
95
|
model: string | null;
|
|
52
96
|
envOverrides: Record<string, string> | null;
|
|
97
|
+
taskType: TaskType | null;
|
|
98
|
+
cloudRepo: string | null;
|
|
99
|
+
cloudBranch: string | null;
|
|
53
100
|
private eventsCache;
|
|
54
101
|
private lastReadPos;
|
|
55
102
|
private baseDir;
|
|
56
|
-
constructor(agentId: string, taskName: string, agentType: AgentType, prompt: string, cwd?: string | null, mode?: Mode, pid?: number | null, status?: AgentStatus, startedAt?: Date, completedAt?: Date | null, baseDir?: string | null, parentSessionId?: string | null, workspaceDir?: string | null, cloudSessionId?: string | null, cloudProvider?: string | null, prUrl?: string | null, version?: string | null, remoteSessionId?: string | null, name?: string | null, after?: string[], effort?: EffortLevel | null, model?: string | null, envOverrides?: Record<string, string> | null);
|
|
103
|
+
constructor(agentId: string, taskName: string, agentType: AgentType, prompt: string, cwd?: string | null, mode?: Mode, pid?: number | null, status?: AgentStatus, startedAt?: Date, completedAt?: Date | null, baseDir?: string | null, parentSessionId?: string | null, workspaceDir?: string | null, cloudSessionId?: string | null, cloudProvider?: string | null, prUrl?: string | null, version?: string | null, remoteSessionId?: string | null, name?: string | null, after?: string[], effort?: EffortLevel | null, model?: string | null, envOverrides?: Record<string, string> | null, taskType?: TaskType | null, cloudRepo?: string | null, cloudBranch?: string | null);
|
|
57
104
|
get isEditMode(): boolean;
|
|
58
105
|
getAgentDir(): Promise<string>;
|
|
106
|
+
/**
|
|
107
|
+
* Dump the subset of state the Ledger sync hook needs. Keeps sync.ts
|
|
108
|
+
* free of any teams-internal imports.
|
|
109
|
+
*/
|
|
110
|
+
toSnapshot(): Promise<{
|
|
111
|
+
agent_id: string;
|
|
112
|
+
team_id: string;
|
|
113
|
+
teammate_name: string | null;
|
|
114
|
+
agent_type: string;
|
|
115
|
+
task_type: string | null;
|
|
116
|
+
status: string;
|
|
117
|
+
started_at: string;
|
|
118
|
+
completed_at: string | null;
|
|
119
|
+
after: string[];
|
|
120
|
+
cloud_provider: string | null;
|
|
121
|
+
cloud_session_id: string | null;
|
|
122
|
+
cloud_repo: string | null;
|
|
123
|
+
cloud_branch: string | null;
|
|
124
|
+
agent_dir: string;
|
|
125
|
+
cwd: string | null;
|
|
126
|
+
}>;
|
|
59
127
|
getStdoutPath(): Promise<string>;
|
|
60
128
|
getMetaPath(): Promise<string>;
|
|
61
129
|
toDict(): any;
|
|
@@ -73,10 +141,24 @@ export declare class AgentProcess {
|
|
|
73
141
|
updateStatusFromProcess(): Promise<void>;
|
|
74
142
|
private reapProcess;
|
|
75
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Manages the full lifecycle of teammate agent processes.
|
|
146
|
+
*
|
|
147
|
+
* Handles spawning (with DAG dependency resolution), status polling,
|
|
148
|
+
* stopping, and automatic cleanup of old agents. Maintains an in-memory
|
|
149
|
+
* cache backed by on-disk meta.json files.
|
|
150
|
+
*/
|
|
151
|
+
/**
|
|
152
|
+
* Callback used to dispatch a cloud-backed teammate when its --after deps
|
|
153
|
+
* resolve. Teams.ts registers one via setCloudDispatcher() at startup; the
|
|
154
|
+
* MCP server path leaves it null (cloud teammates aren't dispatched from MCP).
|
|
155
|
+
*/
|
|
156
|
+
export type CloudDispatchFn = (agent: AgentProcess) => Promise<{
|
|
157
|
+
cloudSessionId: string;
|
|
158
|
+
}>;
|
|
76
159
|
export declare class AgentManager {
|
|
77
160
|
private agents;
|
|
78
161
|
private maxAgents;
|
|
79
|
-
private maxConcurrent;
|
|
80
162
|
private agentsDir;
|
|
81
163
|
private filterByCwd;
|
|
82
164
|
private cleanupAgeDays;
|
|
@@ -84,15 +166,32 @@ export declare class AgentManager {
|
|
|
84
166
|
private agentConfigs;
|
|
85
167
|
private constructorAgentConfigs;
|
|
86
168
|
private initPromise;
|
|
169
|
+
private cloudDispatcher;
|
|
87
170
|
private constructorAgentsDir;
|
|
88
|
-
constructor(maxAgents?: number,
|
|
171
|
+
constructor(maxAgents?: number, agentsDir?: string | null, defaultMode?: Mode | null, filterByCwd?: string | null, cleanupAgeDays?: number, agentConfigs?: Record<AgentType, AgentConfig> | null);
|
|
89
172
|
private initialize;
|
|
90
173
|
private doInitialize;
|
|
91
174
|
getDefaultMode(): Mode;
|
|
92
175
|
setModelOverrides(agentConfigs: Record<AgentType, AgentConfig>): void;
|
|
176
|
+
/**
|
|
177
|
+
* Register the callback used to dispatch cloud-backed teammates when their
|
|
178
|
+
* --after deps resolve. Called once at CLI startup by `agents teams`.
|
|
179
|
+
*/
|
|
180
|
+
setCloudDispatcher(fn: CloudDispatchFn | null): void;
|
|
93
181
|
registerAgent(agent: AgentProcess): void;
|
|
182
|
+
/**
|
|
183
|
+
* Scan the agents dir for meta.json files not already in the in-memory
|
|
184
|
+
* cache and load them. Needed when another process (e.g. a Planner
|
|
185
|
+
* teammate running `agents teams add`) creates new teammates while this
|
|
186
|
+
* manager is alive — the supervisor loop calls this each wave so
|
|
187
|
+
* dynamically-added teammates get picked up.
|
|
188
|
+
*
|
|
189
|
+
* Does not modify or re-load agents already in the cache; that path is
|
|
190
|
+
* covered by updateStatusFromProcess() which re-reads stdout.log.
|
|
191
|
+
*/
|
|
192
|
+
rescanFromDisk(): Promise<number>;
|
|
94
193
|
private loadExistingAgents;
|
|
95
|
-
spawn(taskName: string, agentType: AgentType, prompt: string, cwd?: string | null, mode?: Mode | null, effort?: EffortLevel, parentSessionId?: string | null, workspaceDir?: string | null, version?: string | null, name?: string | null, after?: string[], model?: string | null, envOverrides?: Record<string, string> | null): Promise<AgentProcess>;
|
|
194
|
+
spawn(taskName: string, agentType: AgentType, prompt: string, cwd?: string | null, mode?: Mode | null, effort?: EffortLevel, parentSessionId?: string | null, workspaceDir?: string | null, version?: string | null, name?: string | null, after?: string[], model?: string | null, envOverrides?: Record<string, string> | null, taskType?: TaskType | null, cloudProvider?: string | null, cloudSessionId?: string | null, cloudRepo?: string | null, cloudBranch?: string | null): Promise<AgentProcess>;
|
|
96
195
|
/**
|
|
97
196
|
* Actually spawn the OS process for a teammate. Extracted from spawn() so
|
|
98
197
|
* staged teammates can be launched later by startReady().
|
|
@@ -143,4 +242,3 @@ export declare class AgentManager {
|
|
|
143
242
|
private cleanupPartialAgent;
|
|
144
243
|
private cleanupOldAgents;
|
|
145
244
|
}
|
|
146
|
-
//# sourceMappingURL=agents.d.ts.map
|