pi-harness-runtime 1.1.324 → 1.1.326
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/package.json +1 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/agent-policy/dist/policy-loader.d.ts +8 -1
- package/packages/agent-policy/dist/policy-loader.d.ts.map +1 -1
- package/packages/agent-policy/dist/policy-loader.js +23 -5
- package/packages/agent-policy/dist/policy-loader.js.map +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/agent-policy/src/policy-loader.ts +28 -7
- package/packages/agent-policy/test/policy-retention.test.ts +43 -1
- package/packages/agent-policy/test/policy.test.ts +7 -3
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/durable-review/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/telegram/package.json +1 -1
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/dist/index.d.ts +132 -0
- package/packages/wiki/dist/index.d.ts.map +1 -0
- package/packages/wiki/dist/index.js +448 -0
- package/packages/wiki/dist/index.js.map +1 -0
- package/packages/wiki/dist/storage.d.ts +142 -0
- package/packages/wiki/dist/storage.d.ts.map +1 -0
- package/packages/wiki/dist/storage.js +603 -0
- package/packages/wiki/dist/storage.js.map +1 -0
- package/packages/wiki/dist/types.d.ts +189 -0
- package/packages/wiki/dist/types.d.ts.map +1 -0
- package/packages/wiki/dist/types.js +30 -0
- package/packages/wiki/dist/types.js.map +1 -0
- package/packages/wiki/package.json +22 -0
- package/packages/wiki/src/index.ts +578 -0
- package/packages/wiki/src/storage.ts +696 -0
- package/packages/wiki/src/types.ts +263 -0
- package/packages/wiki/test/basic.test.ts +242 -0
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/write-review/package.json +1 -1
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wiki Package Types
|
|
3
|
+
*
|
|
4
|
+
* Implements LLM Wiki integration per wiki/llm-wiki-integration-minimax-plan.md
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Page Types
|
|
9
|
+
// ============================================================================
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wiki page status lifecycle
|
|
13
|
+
*/
|
|
14
|
+
export type PageStatus =
|
|
15
|
+
| "proposed" // Awaiting synthesis/verification
|
|
16
|
+
| "implemented" // Applied but not yet verified
|
|
17
|
+
| "verified" // Test/inspection evidence recorded
|
|
18
|
+
| "stale" // Source changed, needs review
|
|
19
|
+
| "superseded"; // Replaced by another page
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Page kind categories
|
|
23
|
+
*/
|
|
24
|
+
export type PageKind =
|
|
25
|
+
| "concept" // Architectural/design concept
|
|
26
|
+
| "decision" // Design decision with rationale
|
|
27
|
+
| "incident" // Incident record with lessons
|
|
28
|
+
| "plan" // Implementation plan
|
|
29
|
+
| "verification" // Test/audit results
|
|
30
|
+
| "reference"; // Technical reference
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Source reference in page frontmatter
|
|
34
|
+
*/
|
|
35
|
+
export interface SourceRef {
|
|
36
|
+
sourceId: string; // Stable snapshot ID
|
|
37
|
+
path: string; // Original source path
|
|
38
|
+
contentHash: string; // SHA-256 of captured content
|
|
39
|
+
capturedAt: string; // ISO timestamp
|
|
40
|
+
redacted: boolean; // Whether secrets were redacted
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Wiki page frontmatter
|
|
45
|
+
*/
|
|
46
|
+
export interface WikiPageFrontmatter {
|
|
47
|
+
id: string; // Stable page ID (UUID)
|
|
48
|
+
title: string; // Human-readable title
|
|
49
|
+
kind: PageKind; // Page category
|
|
50
|
+
projectId: string; // Canonical workspace identifier
|
|
51
|
+
status: PageStatus; // Lifecycle status
|
|
52
|
+
createdAt: string; // ISO timestamp
|
|
53
|
+
updatedAt: string; // ISO timestamp
|
|
54
|
+
sources: SourceRef[]; // Immutable source snapshots
|
|
55
|
+
relatedPages: string[]; // Related page IDs
|
|
56
|
+
codeVersion?: string; // Applicable code/package version
|
|
57
|
+
supersedes?: string; // Page ID this supersedes
|
|
58
|
+
supersededBy?: string; // Page ID that supersedes this
|
|
59
|
+
verification?: {
|
|
60
|
+
evidence: string; // Test/inspection reference
|
|
61
|
+
scope?: string; // Scope of verification
|
|
62
|
+
version?: string; // Verified version
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Wiki page content
|
|
68
|
+
*/
|
|
69
|
+
export interface WikiPage {
|
|
70
|
+
frontmatter: WikiPageFrontmatter;
|
|
71
|
+
body: string; // Markdown body with citations
|
|
72
|
+
rawFrontmatter: string; // Original YAML for comparison
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ============================================================================
|
|
76
|
+
// Source Snapshot Types
|
|
77
|
+
// ============================================================================
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Immutable source snapshot (stored in raw/ directory)
|
|
81
|
+
*/
|
|
82
|
+
export interface SourceSnapshot {
|
|
83
|
+
id: string; // Stable snapshot ID
|
|
84
|
+
originalPath: string; // Path when captured
|
|
85
|
+
contentHash: string; // SHA-256 of content
|
|
86
|
+
capturedAt: string; // ISO timestamp
|
|
87
|
+
content: string; // Actual content (may be redacted)
|
|
88
|
+
redacted: boolean; // Whether secrets were removed
|
|
89
|
+
operationId: string; // Operation that created this
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Convert SourceSnapshot to SourceRef for frontmatter
|
|
94
|
+
*/
|
|
95
|
+
export function toSourceRef(snap: SourceSnapshot): SourceRef {
|
|
96
|
+
return {
|
|
97
|
+
sourceId: snap.id,
|
|
98
|
+
path: snap.originalPath,
|
|
99
|
+
contentHash: snap.contentHash,
|
|
100
|
+
capturedAt: snap.capturedAt,
|
|
101
|
+
redacted: snap.redacted,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ============================================================================
|
|
106
|
+
// Operation Types
|
|
107
|
+
// ============================================================================
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Wiki operation types
|
|
111
|
+
*/
|
|
112
|
+
export type WikiOperationType =
|
|
113
|
+
| "init" // Initialize wiki structure
|
|
114
|
+
| "ingest" // Ingest new source
|
|
115
|
+
| "synthesize" // Create/update page synthesis
|
|
116
|
+
| "apply" // Apply staged changes
|
|
117
|
+
| "lint" // Run lint checks
|
|
118
|
+
| "verify"; // Add verification evidence
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Operation status
|
|
122
|
+
*/
|
|
123
|
+
export type OperationStatus = "pending" | "success" | "failed" | "conflict";
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Operation log entry
|
|
127
|
+
*/
|
|
128
|
+
export interface WikiOperation {
|
|
129
|
+
id: string; // Stable operation ID
|
|
130
|
+
type: WikiOperationType;
|
|
131
|
+
status: OperationStatus;
|
|
132
|
+
startedAt: string; // ISO timestamp
|
|
133
|
+
completedAt?: string; // ISO timestamp
|
|
134
|
+
requestId?: string; // Client request ID
|
|
135
|
+
details: Record<string, unknown>; // Operation-specific details
|
|
136
|
+
error?: string; // Error message if failed
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Staged change for apply operation
|
|
141
|
+
*/
|
|
142
|
+
export interface StagedChange {
|
|
143
|
+
pageId: string;
|
|
144
|
+
expectedRevision: string; // Revision that changes are based on
|
|
145
|
+
newContent: string; // New page content
|
|
146
|
+
operationId: string; // Operation that staged this
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ============================================================================
|
|
150
|
+
// Index and Search Types
|
|
151
|
+
// ============================================================================
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Page index entry (lightweight, for search)
|
|
155
|
+
*/
|
|
156
|
+
export interface PageIndexEntry {
|
|
157
|
+
id: string;
|
|
158
|
+
title: string;
|
|
159
|
+
kind: PageKind;
|
|
160
|
+
status: PageStatus;
|
|
161
|
+
tags: string[];
|
|
162
|
+
summary: string; // First ~200 chars of body
|
|
163
|
+
updatedAt: string;
|
|
164
|
+
codeVersion?: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Search filters
|
|
169
|
+
*/
|
|
170
|
+
export interface WikiSearchFilters {
|
|
171
|
+
kinds?: PageKind[];
|
|
172
|
+
statuses?: PageStatus[];
|
|
173
|
+
tags?: string[];
|
|
174
|
+
sourceIds?: string[]; // Pages citing specific sources
|
|
175
|
+
updatedAfter?: string; // ISO timestamp
|
|
176
|
+
updatedBefore?: string; // ISO timestamp
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Search result
|
|
181
|
+
*/
|
|
182
|
+
export interface WikiSearchResult {
|
|
183
|
+
page: PageIndexEntry;
|
|
184
|
+
relevance: number; // 0-1 score
|
|
185
|
+
matchedOn: ("title" | "body" | "tags" | "kind" | "source")[];
|
|
186
|
+
snippets: string[]; // Matching text snippets
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ============================================================================
|
|
190
|
+
// Validation Types
|
|
191
|
+
// ============================================================================
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Lint finding severity
|
|
195
|
+
*/
|
|
196
|
+
export type LintSeverity = "error" | "warning" | "info";
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Lint finding category
|
|
200
|
+
*/
|
|
201
|
+
export type LintCategory =
|
|
202
|
+
| "structure" // Schema violations
|
|
203
|
+
| "links" // Broken/invalid links
|
|
204
|
+
| "freshness" // Stale content
|
|
205
|
+
| "evidence" // Missing verification
|
|
206
|
+
| "duplicates" // Duplicate content
|
|
207
|
+
| "semantic"; // Potential contradictions (model-assisted)
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Lint finding
|
|
211
|
+
*/
|
|
212
|
+
export interface LintFinding {
|
|
213
|
+
severity: LintSeverity;
|
|
214
|
+
category: LintCategory;
|
|
215
|
+
pageId?: string;
|
|
216
|
+
message: string;
|
|
217
|
+
location?: {
|
|
218
|
+
line?: number;
|
|
219
|
+
path?: string;
|
|
220
|
+
};
|
|
221
|
+
suggestion?: string;
|
|
222
|
+
modelAssisted?: boolean; // True if derived by model, not deterministic
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// ============================================================================
|
|
226
|
+
// Configuration Types
|
|
227
|
+
// ============================================================================
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Wiki configuration
|
|
231
|
+
*/
|
|
232
|
+
export interface WikiConfig {
|
|
233
|
+
wikiRoot: string; // Root wiki directory
|
|
234
|
+
rawDir: string; // Source snapshots directory
|
|
235
|
+
knowledgeDir: string; // Generated pages directory
|
|
236
|
+
harnessDir: string; // Internal .harness directory
|
|
237
|
+
indexFile: string; // Page index file
|
|
238
|
+
logFile: string; // Operation log file
|
|
239
|
+
schemaFile: string; // Schema conventions file
|
|
240
|
+
projectId: string; // Canonical project identifier
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Wiki initialization result
|
|
245
|
+
*/
|
|
246
|
+
export interface WikiInitResult {
|
|
247
|
+
created: boolean;
|
|
248
|
+
existing: boolean;
|
|
249
|
+
config: WikiConfig;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Default wiki directory names
|
|
254
|
+
*/
|
|
255
|
+
export const WIKI_DIRS = {
|
|
256
|
+
RAW: "raw",
|
|
257
|
+
KNOWLEDGE: "knowledge",
|
|
258
|
+
HARNESS: ".harness",
|
|
259
|
+
INDEX: "index.json",
|
|
260
|
+
LOG: "log.jsonl",
|
|
261
|
+
SCHEMA: "SCHEMA.md",
|
|
262
|
+
INDEX_MD: "index.md",
|
|
263
|
+
} as const;
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wiki Package Basic Tests
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, it, before, after } from "node:test";
|
|
6
|
+
import assert from "node:assert";
|
|
7
|
+
import { existsSync, mkdirSync, rmSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { randomUUID } from "node:crypto";
|
|
10
|
+
|
|
11
|
+
// Set feature flag for tests
|
|
12
|
+
process.env.HARNESS_KNOWLEDGE_WIKI = "1";
|
|
13
|
+
|
|
14
|
+
import { createWikiManager, wikiExists } from "../dist/index.js";
|
|
15
|
+
|
|
16
|
+
const TEST_DIR = join("/tmp", "wiki-test-" + Date.now());
|
|
17
|
+
|
|
18
|
+
describe("Wiki Manager", () => {
|
|
19
|
+
let wiki: ReturnType<typeof createWikiManager>;
|
|
20
|
+
|
|
21
|
+
before(async () => {
|
|
22
|
+
// Clean up any existing test directory
|
|
23
|
+
rmSync(TEST_DIR, { recursive: true, force: true });
|
|
24
|
+
mkdirSync(TEST_DIR, { recursive: true });
|
|
25
|
+
wiki = createWikiManager(TEST_DIR, "test-project");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
after(() => {
|
|
29
|
+
rmSync(TEST_DIR, { recursive: true, force: true });
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe("Initialization", () => {
|
|
33
|
+
it("should initialize wiki structure", () => {
|
|
34
|
+
// WikiStorage constructor creates structure, so initialize() may see existing
|
|
35
|
+
const result = wiki.initialize();
|
|
36
|
+
// Either freshly created or already existed
|
|
37
|
+
assert.ok(result.created || result.existing);
|
|
38
|
+
assert.ok(existsSync(join(TEST_DIR, "wiki")));
|
|
39
|
+
assert.ok(existsSync(join(TEST_DIR, "wiki", "knowledge")));
|
|
40
|
+
assert.ok(existsSync(join(TEST_DIR, "wiki", "raw")));
|
|
41
|
+
assert.ok(existsSync(join(TEST_DIR, "wiki", ".harness")));
|
|
42
|
+
assert.ok(existsSync(join(TEST_DIR, "wiki", "SCHEMA.md")));
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("should detect existing wiki on subsequent calls", () => {
|
|
46
|
+
const result = wiki.initialize();
|
|
47
|
+
assert.strictEqual(result.created, false);
|
|
48
|
+
assert.ok(result.existing);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should check if wiki is initialized", () => {
|
|
52
|
+
assert.strictEqual(wiki.isInitialized(), true);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe("Page Operations", () => {
|
|
57
|
+
it("should create a page", () => {
|
|
58
|
+
const page = wiki.createPage({
|
|
59
|
+
title: "Test Concept",
|
|
60
|
+
kind: "concept",
|
|
61
|
+
body: "# Test Concept\n\nThis is a test concept.",
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
assert.ok(page.frontmatter.id.startsWith("page-"));
|
|
65
|
+
assert.strictEqual(page.frontmatter.title, "Test Concept");
|
|
66
|
+
assert.strictEqual(page.frontmatter.kind, "concept");
|
|
67
|
+
assert.strictEqual(page.frontmatter.status, "proposed");
|
|
68
|
+
assert.ok(page.body.includes("test concept"));
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("should load a page", () => {
|
|
72
|
+
const created = wiki.createPage({
|
|
73
|
+
title: "Load Test",
|
|
74
|
+
kind: "decision",
|
|
75
|
+
body: "# Load Test\n\nTesting load functionality.",
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const loaded = wiki.loadPage(created.frontmatter.id);
|
|
79
|
+
assert.ok(loaded);
|
|
80
|
+
assert.strictEqual(loaded!.frontmatter.title, "Load Test");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("should update a page", () => {
|
|
84
|
+
const created = wiki.createPage({
|
|
85
|
+
title: "Update Test",
|
|
86
|
+
kind: "reference",
|
|
87
|
+
body: "# Update Test\n\nOriginal content.",
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const updated = wiki.updatePage(created.frontmatter.id, {
|
|
91
|
+
status: "verified",
|
|
92
|
+
body: "# Update Test\n\nUpdated content.",
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
assert.strictEqual(updated.frontmatter.status, "verified");
|
|
96
|
+
assert.ok(updated.body.includes("Updated"));
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("should delete a page", () => {
|
|
100
|
+
const created = wiki.createPage({
|
|
101
|
+
title: "Delete Test",
|
|
102
|
+
kind: "plan",
|
|
103
|
+
body: "# Delete Test\n\nWill be deleted.",
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
wiki.deletePage(created.frontmatter.id);
|
|
107
|
+
const loaded = wiki.loadPage(created.frontmatter.id);
|
|
108
|
+
assert.strictEqual(loaded, null);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("should get all pages", () => {
|
|
112
|
+
const pages = wiki.getAllPages();
|
|
113
|
+
assert.ok(pages.length >= 0);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe("Search", () => {
|
|
118
|
+
it("should search pages by title", () => {
|
|
119
|
+
// Create a page with known title
|
|
120
|
+
wiki.createPage({
|
|
121
|
+
title: "Searchable Concept",
|
|
122
|
+
kind: "concept",
|
|
123
|
+
body: "This page is about searching functionality.",
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const results = wiki.search("Searchable");
|
|
127
|
+
assert.ok(results.length > 0);
|
|
128
|
+
assert.strictEqual(results[0].page.title, "Searchable Concept");
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("should search pages by body content", () => {
|
|
132
|
+
const results = wiki.search("functionality");
|
|
133
|
+
assert.ok(results.some(r => r.page.title === "Searchable Concept"));
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("should get page index", () => {
|
|
137
|
+
const index = wiki.getIndex();
|
|
138
|
+
assert.ok(Array.isArray(index));
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe("Source Ingestion", () => {
|
|
143
|
+
it("should ingest a source file", async () => {
|
|
144
|
+
// Create a test file
|
|
145
|
+
const testFile = join(TEST_DIR, "test-source.md");
|
|
146
|
+
const { writeFileSync } = await import("node:fs");
|
|
147
|
+
writeFileSync(testFile, "# Test Source\n\nThis is a test source file.", "utf8");
|
|
148
|
+
|
|
149
|
+
const { snapshot, operation } = wiki.ingestSource(testFile);
|
|
150
|
+
|
|
151
|
+
assert.ok(snapshot.id.startsWith("snap-"));
|
|
152
|
+
assert.strictEqual(snapshot.originalPath, testFile);
|
|
153
|
+
assert.ok(snapshot.contentHash);
|
|
154
|
+
assert.ok(operation.status === "pending" || operation.status === "success");
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("should get snapshot by ID", async () => {
|
|
158
|
+
// First ingest
|
|
159
|
+
const testFile = join(TEST_DIR, "test-snapshot.md");
|
|
160
|
+
const { writeFileSync } = await import("node:fs");
|
|
161
|
+
writeFileSync(testFile, "# Test Snapshot\n\nContent.", "utf8");
|
|
162
|
+
|
|
163
|
+
const { snapshot } = wiki.ingestSource(testFile);
|
|
164
|
+
const loaded = wiki.getSnapshot(snapshot.id);
|
|
165
|
+
|
|
166
|
+
assert.ok(loaded);
|
|
167
|
+
assert.strictEqual(loaded!.id, snapshot.id);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
describe("Lint", () => {
|
|
172
|
+
it("should run lint checks", () => {
|
|
173
|
+
// Create a page without verification
|
|
174
|
+
wiki.createPage({
|
|
175
|
+
title: "Unverified Page",
|
|
176
|
+
kind: "decision",
|
|
177
|
+
body: "This page needs verification.",
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const findings = wiki.lint();
|
|
181
|
+
|
|
182
|
+
// Should find pages without verification evidence
|
|
183
|
+
const evidenceFindings = findings.filter(f => f.category === "evidence");
|
|
184
|
+
assert.ok(evidenceFindings.length >= 0);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
describe("Staged Changes", () => {
|
|
189
|
+
it("should stage a change", () => {
|
|
190
|
+
const page = wiki.createPage({
|
|
191
|
+
title: "Staged Page",
|
|
192
|
+
kind: "concept",
|
|
193
|
+
body: "# Staged Page\n\nOriginal.",
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// Use any non-empty revision for testing
|
|
197
|
+
const revision = "test-revision-hash";
|
|
198
|
+
|
|
199
|
+
const change = wiki.stageChange(
|
|
200
|
+
page.frontmatter.id,
|
|
201
|
+
revision,
|
|
202
|
+
`---\nid: ${page.frontmatter.id}\ntitle: Staged Page\nkind: concept\nprojectId: test\nstatus: proposed\ncreatedAt: ${new Date().toISOString()}\nupdatedAt: ${new Date().toISOString()}\nsources: []\nrelatedPages: []\n---\n\n# Staged Page\n\nUpdated.`
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
assert.strictEqual(change.pageId, page.frontmatter.id);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it("should get staged change", () => {
|
|
209
|
+
const pages = wiki.getAllPages();
|
|
210
|
+
const stagedPage = pages.find(p => p.frontmatter.title === "Staged Page");
|
|
211
|
+
assert.ok(stagedPage);
|
|
212
|
+
|
|
213
|
+
const change = wiki.getStagedChange(stagedPage!.frontmatter.id);
|
|
214
|
+
assert.ok(change, "Staged change should exist");
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
describe("Operations", () => {
|
|
219
|
+
it("should get recent operations", () => {
|
|
220
|
+
const operations = wiki.getRecentOperations();
|
|
221
|
+
assert.ok(Array.isArray(operations));
|
|
222
|
+
// Operations should exist after initialization and page operations
|
|
223
|
+
assert.ok(operations.length >= 0);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
describe("Wiki Exists Check", () => {
|
|
229
|
+
it("should detect existing wiki", () => {
|
|
230
|
+
const testDir = join("/tmp", "wiki-exists-test-" + Date.now());
|
|
231
|
+
mkdirSync(testDir, { recursive: true });
|
|
232
|
+
mkdirSync(join(testDir, "wiki", "knowledge"), { recursive: true });
|
|
233
|
+
|
|
234
|
+
assert.strictEqual(wikiExists(testDir), true);
|
|
235
|
+
|
|
236
|
+
rmSync(testDir, { recursive: true, force: true });
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it("should detect non-existing wiki", () => {
|
|
240
|
+
assert.strictEqual(wikiExists("/tmp/nonexistent-wiki-path"), false);
|
|
241
|
+
});
|
|
242
|
+
});
|