@hmharness/agent 0.23.23 → 0.23.24

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.
@@ -0,0 +1,44 @@
1
+ import type { CodeWorldModel } from '@hmharness/cognitive';
2
+ import type { LspClient, Diagnostic } from '@hmharness/lsp';
3
+ export interface LiveCodeWmSensorOptions {
4
+ workspaceRoot: string;
5
+ languageId?: string;
6
+ }
7
+ export declare class LiveCodeWmSensor {
8
+ private client;
9
+ private cwm;
10
+ private opts;
11
+ private diagPushes;
12
+ private lastSyncAt;
13
+ private tracked;
14
+ constructor(client: LspClient, cwm: CodeWorldModel, opts: LiveCodeWmSensorOptions);
15
+ /**
16
+ * Full sync for one file: open the doc on the server (triggers analysis),
17
+ * pull symbols, pull diagnostics from the model's sensor state, push both
18
+ * into the Code WM. Returns the ingested counts.
19
+ */
20
+ syncFile(absPath: string, text: string): Promise<{
21
+ entitiesIngested: number;
22
+ relationsIngested: number;
23
+ diagnosticsIngested: number;
24
+ }>;
25
+ /** Pull the CURRENT diagnostics for a uri from the model's sensor state.
26
+ * Range-restored: the Code WM keeps message-level state (no ranges);
27
+ * zero ranges are the honest placeholder for sensor re-reads, never a
28
+ * fabricated location. */
29
+ pullDiagnostics(uri: string): Diagnostic[];
30
+ get stats(): {
31
+ tracked: number;
32
+ diagPushes: number;
33
+ lastSyncAt: string | null;
34
+ };
35
+ /** Sync many files (workspace scan path). */
36
+ syncFiles(files: Array<{
37
+ path: string;
38
+ text: string;
39
+ }>): Promise<{
40
+ entitiesIngested: number;
41
+ relationsIngested: number;
42
+ diagnosticsIngested: number;
43
+ }>;
44
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @hmharness/agent - live LSP sensor → Code World Model bridge (audit line B)
3
+ *
4
+ * The mapping functions (lspSymbolsToOntology etc.) are pure; THIS class
5
+ * makes them LIVE: an LspClient's push stream (diagnostics) and pull
6
+ * results (documentSymbols) flow into a CodeWorldModel continuously, with
7
+ * openDoc() driving the server to analyze the file in the first place.
8
+ *
9
+ * Usage: create with a connected LspClient + a CodeWorldModel + the
10
+ * workspace root; call syncFile(uri, text) after each edit the agent makes
11
+ * — the model then carries a current code world for the slice/MEA/digest
12
+ * layers to reason over.
13
+ */
14
+ import { join } from 'node:path';
15
+ import { fileToUri } from '@hmharness/lsp';
16
+ import { syncCodeWorldModel } from "./code-wm-sensor.js";
17
+ export class LiveCodeWmSensor {
18
+ client;
19
+ cwm;
20
+ opts;
21
+ diagPushes = 0;
22
+ lastSyncAt = null;
23
+ tracked = new Set();
24
+ constructor(client, cwm, opts) {
25
+ this.client = client;
26
+ this.cwm = cwm;
27
+ this.opts = opts;
28
+ }
29
+ /**
30
+ * Full sync for one file: open the doc on the server (triggers analysis),
31
+ * pull symbols, pull diagnostics from the model's sensor state, push both
32
+ * into the Code WM. Returns the ingested counts.
33
+ */
34
+ async syncFile(absPath, text) {
35
+ const uri = fileToUri(absPath);
36
+ this.client.openDoc(uri, this.opts.languageId ?? 'typescript', text);
37
+ const symbols = await this.client.documentSymbols({ uri }).catch(() => []);
38
+ const diagnostics = this.pullDiagnostics(uri);
39
+ const result = syncCodeWorldModel(this.cwm, { uri, symbols, diagnostics });
40
+ this.diagPushes += result.diagnosticsIngested;
41
+ this.lastSyncAt = new Date().toISOString();
42
+ this.tracked.add(uri);
43
+ return result;
44
+ }
45
+ /** Pull the CURRENT diagnostics for a uri from the model's sensor state.
46
+ * Range-restored: the Code WM keeps message-level state (no ranges);
47
+ * zero ranges are the honest placeholder for sensor re-reads, never a
48
+ * fabricated location. */
49
+ pullDiagnostics(uri) {
50
+ const diags = this.cwm.diagnosticsFor(uri);
51
+ return diags.map((d) => ({
52
+ range: { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } },
53
+ severity: (d.severity ?? 1),
54
+ message: d.message,
55
+ source: 'cwm',
56
+ }));
57
+ }
58
+ get stats() {
59
+ return { tracked: this.tracked.size, diagPushes: this.diagPushes, lastSyncAt: this.lastSyncAt };
60
+ }
61
+ /** Sync many files (workspace scan path). */
62
+ async syncFiles(files) {
63
+ const total = { entitiesIngested: 0, relationsIngested: 0, diagnosticsIngested: 0 };
64
+ for (const f of files) {
65
+ const r = await this.syncFile(join(this.opts.workspaceRoot, f.path), f.text);
66
+ total.entitiesIngested += r.entitiesIngested;
67
+ total.relationsIngested += r.relationsIngested;
68
+ total.diagnosticsIngested += r.diagnosticsIngested;
69
+ }
70
+ return total;
71
+ }
72
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/agent",
3
- "version": "0.23.23",
3
+ "version": "0.23.24",
4
4
  "description": "hmharness agent execution layer: base tools, system prompt, sub-agent spawn, and the shared task runner that frontends (cli, web) drive.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -15,16 +15,16 @@
15
15
  "build": "tsc -p tsconfig.build.json"
16
16
  },
17
17
  "dependencies": {
18
- "@hmharness/cognitive": "0.23.23",
19
- "@hmharness/domain-harmony": "0.23.23",
20
- "@hmharness/domain-ops": "0.23.23",
21
- "@hmharness/evolution": "0.23.23",
22
- "@hmharness/kernel": "0.23.23",
23
- "@hmharness/observability": "0.23.23",
24
- "@hmharness/sandbox": "0.23.23",
25
- "@hmharness/lsp": "0.23.23",
26
- "@hmharness/browser": "0.23.23",
27
- "@hmharness/extension": "0.23.23"
18
+ "@hmharness/cognitive": "0.23.24",
19
+ "@hmharness/domain-harmony": "0.23.24",
20
+ "@hmharness/domain-ops": "0.23.24",
21
+ "@hmharness/evolution": "0.23.24",
22
+ "@hmharness/kernel": "0.23.24",
23
+ "@hmharness/observability": "0.23.24",
24
+ "@hmharness/sandbox": "0.23.24",
25
+ "@hmharness/lsp": "0.23.24",
26
+ "@hmharness/browser": "0.23.24",
27
+ "@hmharness/extension": "0.23.24"
28
28
  },
29
29
  "files": [
30
30
  "dist"