@aiwg/cli 2026.10.14 → 2026.10.16
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/agentic/code/addons/aiwg-utils/rules/anti-laziness.core.md +13 -0
- package/agentic/code/addons/aiwg-utils/rules/anti-laziness.md +118 -0
- package/agentic/code/providers/pi/aiwg-bridge.ts +45 -7
- package/dist/src/artifacts/citation-parser.js +7 -6
- package/dist/src/artifacts/corpus-tools/citation-densify.js +4 -2
- package/dist/src/artifacts/corpus-tools/cli.js +37 -0
- package/dist/src/artifacts/corpus-tools/discovery-log.js +27 -25
- package/dist/src/artifacts/corpus-tools/expand-cli.js +90 -0
- package/dist/src/artifacts/corpus-tools/expand-dates.js +107 -0
- package/dist/src/artifacts/corpus-tools/expand-queue.js +41 -0
- package/dist/src/artifacts/corpus-tools/expand-review.js +104 -0
- package/dist/src/artifacts/corpus-tools/expand-state.js +56 -0
- package/dist/src/artifacts/corpus-tools/expand.js +124 -0
- package/dist/src/artifacts/corpus-tools/induction-audit.js +7 -6
- package/dist/src/artifacts/corpus-tools/integrity-scan.js +3 -3
- package/dist/src/artifacts/corpus-tools/radar-shared.js +7 -9
- package/dist/src/artifacts/corpus-tools/ref-files.js +11 -0
- package/dist/src/artifacts/corpus-tools/resolve-cli.js +99 -0
- package/dist/src/artifacts/corpus-tools/resolve-corpus.js +41 -0
- package/dist/src/artifacts/corpus-tools/resolve.js +119 -0
- package/dist/src/artifacts/corpus-tools/retrieval-lab.js +2 -1
- package/dist/src/artifacts/corpus-tools/sidecar-lint.js +4 -4
- package/dist/src/artifacts/corpus-tools/sidecar-repair.js +2 -1
- package/dist/src/artifacts/corpus-views/ref-parser.js +3 -17
- package/dist/src/artifacts/graph-query.js +5 -3
- package/dist/src/artifacts/hybrid-query.js +11 -2
- package/dist/src/artifacts/index-refresh.js +2 -0
- package/dist/src/cli/handlers/daemon.js +17 -1
- package/dist/src/cli/handlers/doctor-args.js +45 -0
- package/dist/src/cli/handlers/doctor-help.js +8 -3
- package/dist/src/cli/handlers/index.js +2 -2
- package/dist/src/cli/handlers/models-resource-sample.js +10 -0
- package/dist/src/cli/handlers/models.js +3 -2
- package/dist/src/cli/handlers/regenerate.js +8 -16
- package/dist/src/cli/handlers/sessions.js +7 -7
- package/dist/src/cli/handlers/subcommands.js +8 -0
- package/dist/src/cli/handlers/update.js +157 -0
- package/dist/src/cli/handlers/use.js +14 -4
- package/dist/src/cli/handlers/utilities.js +3 -586
- package/dist/src/cli/handlers/utility-doctor.js +412 -0
- package/dist/src/cli/services/deployment-verification.js +0 -1
- package/dist/src/config/aiwg-config.js +2 -1
- package/dist/src/config/authorization-cli.js +7 -3
- package/dist/src/config/dispatch-thresholds-runtime.d.mts +3 -2
- package/dist/src/config/dispatch-thresholds-runtime.mjs +17 -7
- package/dist/src/config/framework-aliases.js +12 -0
- package/dist/src/config/host-resource-report.d.mts +19 -0
- package/dist/src/config/host-resource-report.mjs +80 -0
- package/dist/src/config/host-resource-runtime.d.mts +34 -0
- package/dist/src/config/host-resource-runtime.mjs +293 -0
- package/dist/src/config/installed-selection.js +22 -0
- package/dist/src/config/worker-context.js +33 -4
- package/dist/src/config/worker-invocation-marker.d.mts +1 -0
- package/dist/src/config/worker-invocation-marker.mjs +2 -0
- package/dist/src/decision/heldout/access.js +74 -0
- package/dist/src/decision/heldout/calibration.js +1 -0
- package/dist/src/decision/heldout/collector.js +9 -2
- package/dist/src/effects/verifiers/file.js +22 -5
- package/dist/src/extensions/claude-attribution.js +82 -0
- package/dist/src/extensions/claude-hooks-installer.js +115 -69
- package/dist/src/extensions/commands/daemon.js +109 -0
- package/dist/src/extensions/commands/definitions.js +5 -89
- package/dist/src/features/catalog.js +1 -1
- package/dist/src/gates/evaluate.js +2 -2
- package/dist/src/gates/heldout.js +52 -0
- package/dist/src/gates/index.js +2 -1
- package/dist/src/lint/check-patterns.js +163 -0
- package/dist/src/lint/checks.js +268 -0
- package/dist/src/lint/reference-resolution.js +54 -0
- package/dist/src/lint/runner.js +3 -465
- package/dist/src/mcp/helpers.mjs +11 -1
- package/dist/src/memory/project-registry.js +44 -4
- package/dist/src/models/worker-installation-store.mjs +228 -0
- package/dist/src/models/worker-installation.mjs +7 -162
- package/dist/src/models/worker-plan.js +36 -5
- package/dist/src/models/wrapper-deployment.js +25 -12
- package/dist/src/models/wrapper-enforcement.js +47 -7
- package/dist/src/network-analysis/research.js +2 -1
- package/dist/src/policy/hitl-check.js +14 -4
- package/dist/src/policy/hitl-consume.js +54 -0
- package/dist/src/policy/hitl-receipt.js +2 -0
- package/dist/src/policy/hitl.js +11 -3
- package/dist/src/providers/provider-context-contracts.js +162 -0
- package/dist/src/providers/provider-definition-schema.js +136 -0
- package/dist/src/providers/provider-definitions.js +8 -1298
- package/dist/src/providers/provider-seeds-1.js +360 -0
- package/dist/src/providers/provider-seeds-2.js +387 -0
- package/dist/src/providers/provider-seeds-3.js +262 -0
- package/dist/src/research/clients/arxiv.js +14 -34
- package/dist/src/research/clients/base.js +53 -26
- package/dist/src/research/clients/crossref.js +9 -1
- package/dist/src/research/clients/semantic-scholar.js +73 -44
- package/dist/src/research/identity.js +117 -0
- package/dist/src/research/index.js +1 -0
- package/dist/src/research/query-cli.js +3 -87
- package/dist/src/research/query-options.js +87 -0
- package/dist/src/research/reference-match.js +135 -0
- package/dist/src/research/services/acquisition.js +9 -7
- package/dist/src/research/services/citation.js +5 -2
- package/dist/src/research/types.js +2 -0
- package/dist/src/rules/core-startup.d.mts +2 -0
- package/dist/src/rules/core-startup.mjs +31 -0
- package/dist/src/serve/mission-conductor.js +48 -4
- package/dist/src/sessions/adapters/grok-build-native.js +23 -0
- package/dist/src/sessions/adapters/grok-build.js +14 -7
- package/dist/src/sessions/workspace-discovery.js +5 -5
- package/dist/src/smiths/context-pipeline/agents-md.js +34 -0
- package/dist/src/smiths/context-pipeline/aiwg-md.js +19 -46
- package/dist/src/smiths/context-pipeline/bridge-ownership.js +50 -0
- package/dist/src/smiths/context-pipeline/claude-hook.js +1 -1
- package/dist/src/smiths/context-pipeline/code-regions.js +28 -0
- package/dist/src/smiths/context-pipeline/finalization.js +81 -51
- package/dist/src/smiths/context-pipeline/generator.js +49 -114
- package/dist/src/smiths/context-pipeline/managed-hook.js +11 -1
- package/dist/src/smiths/context-pipeline/muse-bridge.js +2 -2
- package/dist/src/smiths/context-pipeline/provider-policy.js +6 -12
- package/dist/src/smiths/context-pipeline/workspace-audit.js +299 -0
- package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +148 -0
- package/dist/src/smiths/context-pipeline/workspace-context-shared.js +111 -0
- package/dist/src/smiths/context-pipeline/workspace-context.js +8 -1373
- package/dist/src/smiths/context-pipeline/workspace-doctor.js +192 -0
- package/dist/src/smiths/context-pipeline/workspace-document.js +201 -0
- package/dist/src/smiths/context-pipeline/workspace-extraction.js +205 -0
- package/dist/src/smiths/context-pipeline/workspace-migration.js +250 -0
- package/package.json +13 -2
- package/schemas/decision/D29Study.v10.schema.json +65 -0
- package/tools/agents/deploy-agents.mjs +12 -123
- package/tools/agents/providers/antigravity.mjs +1 -1
- package/tools/agents/providers/claude-post-deploy.mjs +12 -1
- package/tools/agents/providers/context-write.mjs +16 -0
- package/tools/agents/providers/grok-build.mjs +8 -5
- package/tools/agents/providers/hermes-skill-lifecycle.mjs +144 -0
- package/tools/agents/providers/hermes-startup.mjs +209 -0
- package/tools/agents/providers/hermes.mjs +9 -359
- package/tools/agents/providers/model-wrapper.mjs +5 -1
- package/tools/agents/providers/muse.mjs +3 -3
- package/tools/agents/providers/pi.mjs +4 -2
- package/tools/agents/providers/rule-delivery-surface.mjs +332 -0
- package/tools/agents/providers/rule-delivery.mjs +20 -1346
- package/tools/agents/providers/rule-deployment-commit.mjs +144 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +452 -0
- package/tools/agents/providers/rule-deployment-state.mjs +300 -0
- package/tools/agents/providers/rule-presentation.mjs +13 -4
- package/tools/agents/providers/rule-projection.mjs +119 -0
- package/tools/agents/providers/rule-startup.mjs +70 -0
- package/tools/agents/providers/stale-artifact-prune.mjs +128 -0
- package/tools/agents/providers/warp.mjs +2 -2
- package/tools/agents/providers/windsurf.mjs +11 -57
- package/tools/daemon/README.md +511 -0
- package/tools/daemon/adapters/base-adapter.mjs +84 -0
- package/tools/daemon/adapters/webhook-adapter.mjs +107 -0
- package/tools/daemon/agent-supervisor.mjs +299 -0
- package/tools/daemon/automation-engine.mjs +310 -0
- package/tools/daemon/autonomous-engine.mjs +346 -0
- package/tools/daemon/behavior-loader.mjs +316 -0
- package/tools/daemon/behavior.mjs +174 -0
- package/tools/daemon/concierge/intent-router.mjs +401 -0
- package/tools/daemon/concierge/orchestrator.mjs +272 -0
- package/tools/daemon/concierge/response-translator.mjs +462 -0
- package/tools/daemon/config.mjs +377 -0
- package/tools/daemon/cron-scheduler.mjs +178 -0
- package/tools/daemon/daemon-main.mjs +1169 -0
- package/tools/daemon/event-router.mjs +84 -0
- package/tools/daemon/file-watcher.mjs +383 -0
- package/tools/daemon/index.mjs +1181 -0
- package/tools/daemon/init-profile.mjs +124 -0
- package/tools/daemon/ipc-client.mjs +197 -0
- package/tools/daemon/ipc-ops-handlers.mjs +236 -0
- package/tools/daemon/ipc-server.mjs +275 -0
- package/tools/daemon/maintenance-owner.mjs +79 -0
- package/tools/daemon/memory-manager.mjs +386 -0
- package/tools/daemon/message-router.mjs +194 -0
- package/tools/daemon/provider-watcher.mjs +585 -0
- package/tools/daemon/pty-adapter.mjs +420 -0
- package/tools/daemon/repl-chat.mjs +359 -0
- package/tools/daemon/resource-bounds.mjs +88 -0
- package/tools/daemon/sandbox-transport.mjs +295 -0
- package/tools/daemon/scheduled-task-runner.mjs +535 -0
- package/tools/daemon/task-store.mjs +450 -0
- package/tools/daemon/tmux-manager.mjs +324 -0
- package/tools/daemon/update-policy.mjs +517 -0
- package/tools/daemon/web-server.mjs +399 -0
- package/tools/daemon/web-ui/index.html +585 -0
- package/tools/daemon/web-ui/styles.css +156 -0
- package/tools/docker/Dockerfile.daemon +35 -0
- package/tools/docker/container-manager.mjs +291 -0
- package/tools/messaging/adapter-registry.mjs +230 -0
- package/tools/messaging/adapters/base.mjs +326 -0
- package/tools/messaging/adapters/discord.mjs +462 -0
- package/tools/messaging/adapters/slack.mjs +402 -0
- package/tools/messaging/adapters/telegram.mjs +552 -0
- package/tools/messaging/chat-handler.mjs +297 -0
- package/tools/messaging/command-router.mjs +269 -0
- package/tools/messaging/event-bus.mjs +199 -0
- package/tools/messaging/index.mjs +456 -0
- package/tools/messaging/message-formatter.mjs +320 -0
- package/tools/messaging/room-manager.mjs +277 -0
- package/tools/messaging/types.mjs +94 -0
- package/tools/plugin/plugin-links.mjs +3 -0
- package/tools/providers/pi-bridge-policy.mjs +4 -0
- package/tools/ralph-external/daemon-supervisor.mjs +394 -0
- package/tools/ralph-external/lib/behavior-registry.mjs +270 -0
- package/tools/ralph-external/lib/worker-invocation-processes.mjs +3 -2
- package/tools/ralph-external/lib/worker-isolation-args.mjs +217 -0
- package/tools/ralph-external/lib/worker-isolation-status.mjs +19 -0
- package/tools/ralph-external/lib/worker-isolation.mjs +11 -237
- package/tools/ralph-external/lib/worker-overflow.mjs +10 -2
- package/tools/ralph-external/lib/worker-unit-cleanup.mjs +72 -0
- package/tools/ralph-external/session-launcher.mjs +7 -7
- package/tools/scripts/resource-preflight.mjs +3 -242
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Platform Watcher
|
|
3
|
+
*
|
|
4
|
+
* Monitors provider platforms (Claude Code, Cursor, Copilot, etc.) for
|
|
5
|
+
* upstream changes and emits events when new versions, doc updates, or
|
|
6
|
+
* breaking changes are detected.
|
|
7
|
+
*
|
|
8
|
+
* Integrates with the daemon's CronScheduler via event emission and can
|
|
9
|
+
* also be invoked manually via IPC.
|
|
10
|
+
*
|
|
11
|
+
* @see https://git.integrolabs.net/roctinam/aiwg/issues/615
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { EventEmitter } from 'events';
|
|
15
|
+
import fs from 'fs';
|
|
16
|
+
import path from 'path';
|
|
17
|
+
import { importImpl } from '../_resolve-impl.mjs';
|
|
18
|
+
|
|
19
|
+
const { boundedExecFileSync } = await importImpl(import.meta.url, 'process/bounded-child-process.mjs');
|
|
20
|
+
const { cliCommand } = await importImpl(import.meta.url, 'process/cli-command.mjs');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Source definition for a single provider watch target.
|
|
24
|
+
* @typedef {Object} WatchSource
|
|
25
|
+
* @property {string} type - Source type: 'npm' | 'github-release' | 'changelog-url' | 'docs-url'
|
|
26
|
+
* @property {string} url - URL or package name to monitor
|
|
27
|
+
* @property {string} [path] - Subpath for docs or changelog scraping
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Provider definition with all watch sources.
|
|
32
|
+
* @typedef {Object} ProviderDef
|
|
33
|
+
* @property {string} id - Provider identifier (matches capability-matrix.yaml)
|
|
34
|
+
* @property {string} displayName - Human-readable name
|
|
35
|
+
* @property {WatchSource[]} sources - Ordered list of watch sources
|
|
36
|
+
* @property {string[]} referenceFiles - Local files to update when changes detected
|
|
37
|
+
* @property {string[]} integrationDocs - Integration docs that may need updating
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/** Built-in provider source definitions */
|
|
41
|
+
const PROVIDER_SOURCES = [
|
|
42
|
+
{
|
|
43
|
+
id: 'claude-code',
|
|
44
|
+
displayName: 'Claude Code',
|
|
45
|
+
sources: [
|
|
46
|
+
{ type: 'npm', url: '@anthropic-ai/claude-code' },
|
|
47
|
+
{ type: 'github-release', url: 'anthropics/claude-code' },
|
|
48
|
+
{ type: 'docs-url', url: 'https://docs.anthropic.com/en/docs/claude-code' },
|
|
49
|
+
],
|
|
50
|
+
referenceFiles: ['.aiwg/references/platforms/claude-code.md'],
|
|
51
|
+
integrationDocs: [],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: 'cursor',
|
|
55
|
+
displayName: 'Cursor',
|
|
56
|
+
sources: [
|
|
57
|
+
{ type: 'changelog-url', url: 'https://www.cursor.com/changelog' },
|
|
58
|
+
{ type: 'docs-url', url: 'https://docs.cursor.com' },
|
|
59
|
+
],
|
|
60
|
+
referenceFiles: ['.aiwg/references/platforms/cursor.md'],
|
|
61
|
+
integrationDocs: ['docs/integrations/cursor-quickstart.md'],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'copilot',
|
|
65
|
+
displayName: 'GitHub Copilot',
|
|
66
|
+
sources: [
|
|
67
|
+
{ type: 'github-release', url: 'github/copilot-docs' },
|
|
68
|
+
{ type: 'docs-url', url: 'https://docs.github.com/en/copilot' },
|
|
69
|
+
],
|
|
70
|
+
referenceFiles: ['.aiwg/references/platforms/github-copilot.md'],
|
|
71
|
+
integrationDocs: [],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: 'factory',
|
|
75
|
+
displayName: 'Factory AI',
|
|
76
|
+
sources: [
|
|
77
|
+
{ type: 'docs-url', url: 'https://docs.factory.ai' },
|
|
78
|
+
],
|
|
79
|
+
referenceFiles: ['.aiwg/references/platforms/factory-ai.md'],
|
|
80
|
+
integrationDocs: [],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: 'windsurf',
|
|
84
|
+
displayName: 'Windsurf',
|
|
85
|
+
sources: [
|
|
86
|
+
{ type: 'changelog-url', url: 'https://windsurf.com/changelog' },
|
|
87
|
+
{ type: 'docs-url', url: 'https://docs.windsurf.com' },
|
|
88
|
+
],
|
|
89
|
+
referenceFiles: ['.aiwg/references/platforms/windsurf.md'],
|
|
90
|
+
integrationDocs: [],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: 'warp',
|
|
94
|
+
displayName: 'Warp',
|
|
95
|
+
sources: [
|
|
96
|
+
{ type: 'docs-url', url: 'https://docs.warp.dev' },
|
|
97
|
+
],
|
|
98
|
+
referenceFiles: ['.aiwg/references/platforms/warp.md'],
|
|
99
|
+
integrationDocs: [],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: 'codex',
|
|
103
|
+
displayName: 'OpenAI Codex CLI',
|
|
104
|
+
sources: [
|
|
105
|
+
{ type: 'npm', url: '@openai/codex' },
|
|
106
|
+
{ type: 'github-release', url: 'openai/codex' },
|
|
107
|
+
],
|
|
108
|
+
referenceFiles: [],
|
|
109
|
+
integrationDocs: [],
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: 'opencode',
|
|
113
|
+
displayName: 'OpenCode',
|
|
114
|
+
sources: [
|
|
115
|
+
{ type: 'npm', url: 'opencode' },
|
|
116
|
+
{ type: 'github-release', url: 'opencode-ai/opencode' },
|
|
117
|
+
],
|
|
118
|
+
referenceFiles: ['.aiwg/references/platforms/opencode.md'],
|
|
119
|
+
integrationDocs: [],
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: 'openclaw',
|
|
123
|
+
displayName: 'OpenClaw',
|
|
124
|
+
sources: [
|
|
125
|
+
{ type: 'docs-url', url: 'https://docs.openclaw.ai' },
|
|
126
|
+
],
|
|
127
|
+
referenceFiles: ['.aiwg/references/platforms/openclaw.md'],
|
|
128
|
+
integrationDocs: [],
|
|
129
|
+
},
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
export class ProviderWatcher extends EventEmitter {
|
|
133
|
+
/**
|
|
134
|
+
* @param {Object} options
|
|
135
|
+
* @param {string} options.stateDir - Directory for persisting watcher state
|
|
136
|
+
* @param {string[]} [options.providers] - Provider IDs to watch (default: all)
|
|
137
|
+
* @param {number} [options.intervalHours] - Check interval in hours (default: 6)
|
|
138
|
+
*/
|
|
139
|
+
constructor(options = {}) {
|
|
140
|
+
super();
|
|
141
|
+
this.stateDir = options.stateDir || '.aiwg/daemon/provider-watch';
|
|
142
|
+
this.providers = options.providers || PROVIDER_SOURCES.map((p) => p.id);
|
|
143
|
+
this.intervalHours = options.intervalHours || 6;
|
|
144
|
+
// npm keeps its own config/registry variables; only daemon secrets are removed.
|
|
145
|
+
this.environment = options.environment;
|
|
146
|
+
this.statePath = path.join(this.stateDir, 'state.json');
|
|
147
|
+
this.state = this.loadState();
|
|
148
|
+
this._intervalHandle = null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Start periodic checking on the configured interval.
|
|
153
|
+
* Runs an initial check immediately, then every `intervalHours`.
|
|
154
|
+
*/
|
|
155
|
+
start() {
|
|
156
|
+
if (this._intervalHandle) return; // already running
|
|
157
|
+
|
|
158
|
+
// Run first check after a short delay (30s) to let daemon finish init
|
|
159
|
+
const initialDelay = setTimeout(() => {
|
|
160
|
+
this.checkAll().catch((err) =>
|
|
161
|
+
this.emit('error', { provider: '*', error: err.message })
|
|
162
|
+
);
|
|
163
|
+
}, 30_000);
|
|
164
|
+
initialDelay.unref?.();
|
|
165
|
+
|
|
166
|
+
// Schedule recurring checks
|
|
167
|
+
const intervalMs = this.intervalHours * 60 * 60 * 1000;
|
|
168
|
+
this._intervalHandle = setInterval(() => {
|
|
169
|
+
this.checkAll().catch((err) =>
|
|
170
|
+
this.emit('error', { provider: '*', error: err.message })
|
|
171
|
+
);
|
|
172
|
+
}, intervalMs);
|
|
173
|
+
this._intervalHandle.unref?.();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Stop periodic checking. Safe to call multiple times.
|
|
178
|
+
*/
|
|
179
|
+
stop() {
|
|
180
|
+
if (this._intervalHandle) {
|
|
181
|
+
clearInterval(this._intervalHandle);
|
|
182
|
+
this._intervalHandle = null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Load persisted state (last-seen versions, timestamps). */
|
|
187
|
+
loadState() {
|
|
188
|
+
try {
|
|
189
|
+
if (fs.existsSync(this.statePath)) {
|
|
190
|
+
return JSON.parse(fs.readFileSync(this.statePath, 'utf-8'));
|
|
191
|
+
}
|
|
192
|
+
} catch {
|
|
193
|
+
// Corrupted state — reset
|
|
194
|
+
}
|
|
195
|
+
return { providers: {}, lastFullCheck: null };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Persist state to disk. */
|
|
199
|
+
saveState() {
|
|
200
|
+
fs.mkdirSync(this.stateDir, { recursive: true });
|
|
201
|
+
const tmp = `${this.statePath}.tmp`;
|
|
202
|
+
fs.writeFileSync(tmp, JSON.stringify(this.state, null, 2));
|
|
203
|
+
fs.renameSync(tmp, this.statePath);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Run a full check across all watched providers.
|
|
208
|
+
* Emits 'change' events for each detected update.
|
|
209
|
+
* @returns {Promise<ChangeReport[]>} Array of detected changes
|
|
210
|
+
*/
|
|
211
|
+
async checkAll() {
|
|
212
|
+
const changes = [];
|
|
213
|
+
const activeProviders = PROVIDER_SOURCES.filter((p) =>
|
|
214
|
+
this.providers.includes(p.id)
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
for (const provider of activeProviders) {
|
|
218
|
+
try {
|
|
219
|
+
const providerChanges = await this.checkProvider(provider);
|
|
220
|
+
changes.push(...providerChanges);
|
|
221
|
+
} catch (error) {
|
|
222
|
+
this.emit('error', {
|
|
223
|
+
provider: provider.id,
|
|
224
|
+
error: error.message,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
this.state.lastFullCheck = new Date().toISOString();
|
|
230
|
+
this.saveState();
|
|
231
|
+
|
|
232
|
+
if (changes.length > 0) {
|
|
233
|
+
this.emit('changes-detected', { changes, timestamp: new Date().toISOString() });
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return changes;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Check a single provider for upstream changes.
|
|
241
|
+
* @param {ProviderDef} provider
|
|
242
|
+
* @returns {Promise<ChangeReport[]>}
|
|
243
|
+
*/
|
|
244
|
+
async checkProvider(provider) {
|
|
245
|
+
const changes = [];
|
|
246
|
+
const providerState = this.state.providers[provider.id] || {
|
|
247
|
+
lastCheck: null,
|
|
248
|
+
lastSeenVersions: {},
|
|
249
|
+
lastSeenHashes: {},
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
for (const source of provider.sources) {
|
|
253
|
+
try {
|
|
254
|
+
const result = await this.checkSource(provider.id, source, providerState);
|
|
255
|
+
if (result) {
|
|
256
|
+
changes.push({
|
|
257
|
+
provider: provider.id,
|
|
258
|
+
displayName: provider.displayName,
|
|
259
|
+
source: source.type,
|
|
260
|
+
sourceUrl: source.url,
|
|
261
|
+
...result,
|
|
262
|
+
referenceFiles: provider.referenceFiles,
|
|
263
|
+
integrationDocs: provider.integrationDocs,
|
|
264
|
+
detectedAt: new Date().toISOString(),
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
} catch (error) {
|
|
268
|
+
this.emit('source-error', {
|
|
269
|
+
provider: provider.id,
|
|
270
|
+
source: source.type,
|
|
271
|
+
url: source.url,
|
|
272
|
+
error: error.message,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
providerState.lastCheck = new Date().toISOString();
|
|
278
|
+
this.state.providers[provider.id] = providerState;
|
|
279
|
+
|
|
280
|
+
return changes;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Check a single source for changes.
|
|
285
|
+
* @param {string} providerId
|
|
286
|
+
* @param {WatchSource} source
|
|
287
|
+
* @param {Object} providerState
|
|
288
|
+
* @returns {Promise<Object|null>} Change details or null if no change
|
|
289
|
+
*/
|
|
290
|
+
async checkSource(providerId, source, providerState) {
|
|
291
|
+
switch (source.type) {
|
|
292
|
+
case 'npm':
|
|
293
|
+
return this.checkNpm(providerId, source, providerState);
|
|
294
|
+
case 'github-release':
|
|
295
|
+
return this.checkGithubRelease(providerId, source, providerState);
|
|
296
|
+
case 'changelog-url':
|
|
297
|
+
return this.checkChangelog(providerId, source, providerState);
|
|
298
|
+
case 'docs-url':
|
|
299
|
+
return this.checkDocs(providerId, source, providerState);
|
|
300
|
+
default:
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Check npm registry for new versions.
|
|
307
|
+
* Uses `npm view` to avoid needing an npm token.
|
|
308
|
+
*/
|
|
309
|
+
async checkNpm(providerId, source, providerState) {
|
|
310
|
+
const pkg = source.url;
|
|
311
|
+
|
|
312
|
+
try {
|
|
313
|
+
const [file, args] = cliCommand('npm', ['view', pkg, 'version', 'dist-tags', '--json']);
|
|
314
|
+
const output = boundedExecFileSync(file, args, 'quick', {
|
|
315
|
+
env: this.environment ?? process.env,
|
|
316
|
+
encoding: 'utf-8',
|
|
317
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
318
|
+
});
|
|
319
|
+
const data = JSON.parse(output);
|
|
320
|
+
const latestVersion = typeof data === 'string' ? data : data.version || data['dist-tags']?.latest;
|
|
321
|
+
|
|
322
|
+
if (!latestVersion) return null;
|
|
323
|
+
|
|
324
|
+
const lastSeen = providerState.lastSeenVersions[`npm:${pkg}`];
|
|
325
|
+
if (lastSeen === latestVersion) return null;
|
|
326
|
+
|
|
327
|
+
providerState.lastSeenVersions[`npm:${pkg}`] = latestVersion;
|
|
328
|
+
|
|
329
|
+
return {
|
|
330
|
+
type: 'new-version',
|
|
331
|
+
previousVersion: lastSeen || '(first check)',
|
|
332
|
+
newVersion: latestVersion,
|
|
333
|
+
impact: lastSeen ? 'medium' : 'low',
|
|
334
|
+
summary: `${pkg} updated to ${latestVersion}${lastSeen ? ` (was ${lastSeen})` : ''}`,
|
|
335
|
+
};
|
|
336
|
+
} catch {
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Check GitHub releases API for new releases.
|
|
343
|
+
* Uses unauthenticated API (60 req/hr limit — fine for 6-hour intervals).
|
|
344
|
+
*/
|
|
345
|
+
async checkGithubRelease(providerId, source, providerState) {
|
|
346
|
+
const repo = source.url;
|
|
347
|
+
const apiUrl = `https://api.github.com/repos/${repo}/releases/latest`;
|
|
348
|
+
|
|
349
|
+
try {
|
|
350
|
+
const response = await fetch(apiUrl, {
|
|
351
|
+
headers: { 'User-Agent': 'AIWG-Provider-Watcher/1.0' },
|
|
352
|
+
signal: AbortSignal.timeout(15000),
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
if (!response.ok) return null;
|
|
356
|
+
|
|
357
|
+
const data = await response.json();
|
|
358
|
+
const tagName = data.tag_name;
|
|
359
|
+
const lastSeen = providerState.lastSeenVersions[`github:${repo}`];
|
|
360
|
+
|
|
361
|
+
if (lastSeen === tagName) return null;
|
|
362
|
+
|
|
363
|
+
providerState.lastSeenVersions[`github:${repo}`] = tagName;
|
|
364
|
+
|
|
365
|
+
const isBreaking = (data.body || '').toLowerCase().includes('breaking');
|
|
366
|
+
|
|
367
|
+
return {
|
|
368
|
+
type: 'new-release',
|
|
369
|
+
previousVersion: lastSeen || '(first check)',
|
|
370
|
+
newVersion: tagName,
|
|
371
|
+
impact: isBreaking ? 'high' : 'medium',
|
|
372
|
+
summary: `${repo} released ${tagName}${lastSeen ? ` (was ${lastSeen})` : ''}`,
|
|
373
|
+
releaseNotes: (data.body || '').slice(0, 2000),
|
|
374
|
+
releaseUrl: data.html_url,
|
|
375
|
+
};
|
|
376
|
+
} catch {
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Check a changelog URL for new content.
|
|
383
|
+
* Computes a content hash and compares to last seen.
|
|
384
|
+
*/
|
|
385
|
+
async checkChangelog(providerId, source, providerState) {
|
|
386
|
+
try {
|
|
387
|
+
const response = await fetch(source.url, {
|
|
388
|
+
headers: { 'User-Agent': 'AIWG-Provider-Watcher/1.0' },
|
|
389
|
+
signal: AbortSignal.timeout(15000),
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
if (!response.ok) return null;
|
|
393
|
+
|
|
394
|
+
const text = await response.text();
|
|
395
|
+
const { createHash } = await import('crypto');
|
|
396
|
+
const hash = createHash('sha256').update(text).digest('hex').slice(0, 16);
|
|
397
|
+
const lastHash = providerState.lastSeenHashes[`changelog:${source.url}`];
|
|
398
|
+
|
|
399
|
+
if (lastHash === hash) return null;
|
|
400
|
+
|
|
401
|
+
providerState.lastSeenHashes[`changelog:${source.url}`] = hash;
|
|
402
|
+
|
|
403
|
+
if (!lastHash) return null; // First check — no diff to report
|
|
404
|
+
|
|
405
|
+
return {
|
|
406
|
+
type: 'changelog-update',
|
|
407
|
+
impact: 'low',
|
|
408
|
+
summary: `Changelog updated at ${source.url}`,
|
|
409
|
+
contentHash: hash,
|
|
410
|
+
};
|
|
411
|
+
} catch {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Check a documentation URL for content changes.
|
|
418
|
+
* Same hash-based approach as changelog.
|
|
419
|
+
*/
|
|
420
|
+
async checkDocs(providerId, source, providerState) {
|
|
421
|
+
try {
|
|
422
|
+
const response = await fetch(source.url, {
|
|
423
|
+
headers: { 'User-Agent': 'AIWG-Provider-Watcher/1.0' },
|
|
424
|
+
signal: AbortSignal.timeout(15000),
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
if (!response.ok) return null;
|
|
428
|
+
|
|
429
|
+
const text = await response.text();
|
|
430
|
+
const { createHash } = await import('crypto');
|
|
431
|
+
const hash = createHash('sha256').update(text).digest('hex').slice(0, 16);
|
|
432
|
+
const lastHash = providerState.lastSeenHashes[`docs:${source.url}`];
|
|
433
|
+
|
|
434
|
+
if (lastHash === hash) return null;
|
|
435
|
+
|
|
436
|
+
providerState.lastSeenHashes[`docs:${source.url}`] = hash;
|
|
437
|
+
|
|
438
|
+
if (!lastHash) return null; // First check
|
|
439
|
+
|
|
440
|
+
return {
|
|
441
|
+
type: 'docs-update',
|
|
442
|
+
impact: 'low',
|
|
443
|
+
summary: `Documentation updated at ${source.url}`,
|
|
444
|
+
contentHash: hash,
|
|
445
|
+
};
|
|
446
|
+
} catch {
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Generate a structured PR body from detected changes.
|
|
453
|
+
* @param {ChangeReport[]} changes
|
|
454
|
+
* @returns {string} Markdown-formatted PR body
|
|
455
|
+
*/
|
|
456
|
+
static generatePRBody(changes) {
|
|
457
|
+
if (!changes.length) return '';
|
|
458
|
+
|
|
459
|
+
const byProvider = {};
|
|
460
|
+
for (const change of changes) {
|
|
461
|
+
if (!byProvider[change.provider]) {
|
|
462
|
+
byProvider[change.provider] = { displayName: change.displayName, changes: [] };
|
|
463
|
+
}
|
|
464
|
+
byProvider[change.provider].changes.push(change);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const impactOrder = { high: 0, medium: 1, low: 2 };
|
|
468
|
+
const maxImpact = changes.reduce(
|
|
469
|
+
(max, c) => (impactOrder[c.impact] < impactOrder[max] ? c.impact : max),
|
|
470
|
+
'low'
|
|
471
|
+
);
|
|
472
|
+
|
|
473
|
+
const lines = [];
|
|
474
|
+
lines.push(`## Provider Updates Detected`);
|
|
475
|
+
lines.push('');
|
|
476
|
+
lines.push(`**Impact**: ${maxImpact.charAt(0).toUpperCase() + maxImpact.slice(1)}`);
|
|
477
|
+
lines.push(`**Detected**: ${new Date().toISOString().split('T')[0]}`);
|
|
478
|
+
lines.push(`**Providers affected**: ${Object.keys(byProvider).length}`);
|
|
479
|
+
lines.push('');
|
|
480
|
+
|
|
481
|
+
for (const [id, { displayName, changes: provChanges }] of Object.entries(byProvider)) {
|
|
482
|
+
lines.push(`### ${displayName}`);
|
|
483
|
+
lines.push('');
|
|
484
|
+
for (const c of provChanges) {
|
|
485
|
+
lines.push(`- **${c.type}**: ${c.summary}`);
|
|
486
|
+
if (c.releaseUrl) lines.push(` - Release: ${c.releaseUrl}`);
|
|
487
|
+
}
|
|
488
|
+
lines.push('');
|
|
489
|
+
|
|
490
|
+
const refFiles = provChanges.flatMap((c) => c.referenceFiles || []);
|
|
491
|
+
const docFiles = provChanges.flatMap((c) => c.integrationDocs || []);
|
|
492
|
+
const allFiles = [...new Set([...refFiles, ...docFiles])];
|
|
493
|
+
if (allFiles.length) {
|
|
494
|
+
lines.push('**Files to review**:');
|
|
495
|
+
for (const f of allFiles) {
|
|
496
|
+
lines.push(`- \`${f}\``);
|
|
497
|
+
}
|
|
498
|
+
lines.push('');
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
lines.push('### Requires Human Review');
|
|
503
|
+
lines.push('');
|
|
504
|
+
for (const change of changes.filter((c) => c.impact === 'high')) {
|
|
505
|
+
lines.push(`- [ ] ${change.displayName}: ${change.summary}`);
|
|
506
|
+
}
|
|
507
|
+
if (!changes.some((c) => c.impact === 'high')) {
|
|
508
|
+
lines.push('No high-impact changes detected.');
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
return lines.join('\n');
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Get the cron expression for the daemon scheduler.
|
|
516
|
+
* @returns {string} Cron expression for the configured interval
|
|
517
|
+
*/
|
|
518
|
+
getCronExpression() {
|
|
519
|
+
// Run at minute 0, every N hours
|
|
520
|
+
return `0 */${this.intervalHours} * * *`;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/** Get provider source definitions (for inspection/config). */
|
|
524
|
+
static getProviderSources() {
|
|
525
|
+
return PROVIDER_SOURCES;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Return the default automation rule for PR creation on provider changes.
|
|
530
|
+
* Register this with the AutomationEngine so `provider.changes` events
|
|
531
|
+
* automatically dispatch an agent task to create a PR.
|
|
532
|
+
* @returns {Object} Automation rule definition
|
|
533
|
+
*/
|
|
534
|
+
static getAutomationRule() {
|
|
535
|
+
return {
|
|
536
|
+
id: 'provider-watch-pr',
|
|
537
|
+
description: 'Create PR when provider changes are detected',
|
|
538
|
+
trigger: {
|
|
539
|
+
source: 'provider-watch',
|
|
540
|
+
type: 'provider.changes',
|
|
541
|
+
},
|
|
542
|
+
action: {
|
|
543
|
+
type: 'agent',
|
|
544
|
+
agent: 'aiwg-steward',
|
|
545
|
+
priority: 1,
|
|
546
|
+
prompt: [
|
|
547
|
+
'Provider platform changes have been detected by the ProviderWatcher daemon.',
|
|
548
|
+
'',
|
|
549
|
+
'Changes payload is available in the event context. Your task:',
|
|
550
|
+
'1. Read the changes from `.aiwg/daemon/provider-watch/state.json`',
|
|
551
|
+
'2. Run `ProviderWatcher.generatePRBody(changes)` or format equivalently',
|
|
552
|
+
'3. Create a new branch: `provider-updates/{date}`',
|
|
553
|
+
'4. Update any affected reference files listed in the changes',
|
|
554
|
+
'5. Commit changes and open a PR to main with the structured body',
|
|
555
|
+
'6. PR must require human review before merge (never auto-merge)',
|
|
556
|
+
'',
|
|
557
|
+
'If no reference files need updating, create an informational issue instead.',
|
|
558
|
+
].join('\n'),
|
|
559
|
+
},
|
|
560
|
+
requiresApproval: false,
|
|
561
|
+
cooldownMs: 6 * 60 * 60 * 1000, // 6 hours — match watcher interval
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/** Get status summary for IPC/CLI. */
|
|
566
|
+
getStatus() {
|
|
567
|
+
return {
|
|
568
|
+
watching: this.providers,
|
|
569
|
+
intervalHours: this.intervalHours,
|
|
570
|
+
lastFullCheck: this.state.lastFullCheck,
|
|
571
|
+
providers: Object.fromEntries(
|
|
572
|
+
Object.entries(this.state.providers).map(([id, s]) => [
|
|
573
|
+
id,
|
|
574
|
+
{
|
|
575
|
+
lastCheck: s.lastCheck,
|
|
576
|
+
versionsTracked: Object.keys(s.lastSeenVersions || {}).length,
|
|
577
|
+
hashesTracked: Object.keys(s.lastSeenHashes || {}).length,
|
|
578
|
+
},
|
|
579
|
+
])
|
|
580
|
+
),
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
export default ProviderWatcher;
|