Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function makeContext(): AgentContext {
},
knowledge: [],
skills: [],
targetRealm: 'https://realms.example.test/hassan/personal/',
targetRealm: 'https://realms.example.test/testuser/personal/',
// System-prompt rendering requires this — see requireDarkfactoryModuleUrl.
darkfactoryModuleUrl:
'https://realms.example.test/software-factory/darkfactory',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function makeContext(): AgentContext {
issue: { id: 'Issues/demo', issueType: 'feature' },
knowledge: [],
skills: [],
targetRealm: 'https://realms.example.test/hassan/personal/',
targetRealm: 'https://realms.example.test/testuser/personal/',
// Required for system-prompt rendering (see requireDarkfactoryModuleUrl).
darkfactoryModuleUrl:
'https://realms.example.test/software-factory/darkfactory',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ module('factory-entrypoint integration', function () {
JSON.stringify({
access_token: 'matrix-access-token',
device_id: 'device-id',
user_id: '@hassan:localhost',
user_id: '@testuser:localhost',
}),
);
} else if (
request.url ===
'/_matrix/client/v3/user/%40hassan%3Alocalhost/openid/request_token' &&
'/_matrix/client/v3/user/%40testuser%3Alocalhost/openid/request_token' &&
request.method === 'POST'
) {
response.writeHead(200, { 'content-type': SupportedMimeType.JSON });
Expand Down Expand Up @@ -143,14 +143,14 @@ module('factory-entrypoint integration', function () {
);
} else if (
request.url ===
'/_matrix/client/v3/user/%40hassan%3Alocalhost/account_data/app.boxel.realms' &&
'/_matrix/client/v3/user/%40testuser%3Alocalhost/account_data/app.boxel.realms' &&
request.method === 'GET'
) {
response.writeHead(200, { 'content-type': SupportedMimeType.JSON });
response.end(JSON.stringify({ realms: [] }));
} else if (
request.url ===
'/_matrix/client/v3/user/%40hassan%3Alocalhost/account_data/app.boxel.realms' &&
'/_matrix/client/v3/user/%40testuser%3Alocalhost/account_data/app.boxel.realms' &&
request.method === 'PUT'
) {
response.writeHead(200, { 'content-type': SupportedMimeType.JSON });
Expand All @@ -177,15 +177,15 @@ module('factory-entrypoint integration', function () {
}),
);
} else if (
request.url === '/hassan/personal/_search' &&
request.url === '/testuser/personal/_search' &&
request.method === 'QUERY'
) {
// Issue store search — return empty so the loop exits cleanly
// and reports 'all_issues_done'.
response.writeHead(200, { 'content-type': SupportedMimeType.CardJson });
response.end(JSON.stringify({ data: [] }));
} else if (
request.url === '/hassan/personal/_mtimes' &&
request.url === '/testuser/personal/_mtimes' &&
request.method === 'GET'
) {
// Used by client.pull / client.sync to list remote state. The
Expand All @@ -195,7 +195,7 @@ module('factory-entrypoint integration', function () {
response.writeHead(200, { 'content-type': SupportedMimeType.JSONAPI });
response.end(JSON.stringify({ data: { attributes: { mtimes: {} } } }));
} else if (
request.url === '/hassan/personal/_atomic' &&
request.url?.startsWith('/testuser/personal/_atomic') &&
request.method === 'POST'
) {
// Used by client.sync to atomically push card writes. Parse the
Expand All @@ -217,7 +217,7 @@ module('factory-entrypoint integration', function () {
if (op.op === 'add' || op.op === 'update') {
let href = op.href ?? '';
let path = href
.replace(/^https?:\/\/[^/]+\/hassan\/personal\//, '')
.replace(/^https?:\/\/[^/]+\/testuser\/personal\//, '')
.replace(/^\.\/?/, '')
.replace(/\.json$/, '');
createdCardPaths.add(path);
Expand All @@ -234,15 +234,15 @@ module('factory-entrypoint integration', function () {
});
return;
} else if (
request.url === '/hassan/personal/_readiness-check' &&
request.url === '/testuser/personal/_readiness-check' &&
request.method === 'GET'
) {
response.writeHead(200, {
'content-type': 'text/html',
});
response.end('');
} else if (
request.url === '/hassan/personal/_session' &&
request.url === '/testuser/personal/_session' &&
request.method === 'POST'
) {
// Realm session for target realm auth
Expand All @@ -252,11 +252,11 @@ module('factory-entrypoint integration', function () {
});
response.end('');
} else if (
request.url?.startsWith('/hassan/personal/') &&
request.url?.startsWith('/testuser/personal/') &&
request.method === 'GET'
) {
let cardPath = request.url
.replace('/hassan/personal/', '')
.replace('/testuser/personal/', '')
.replace(/\.json$/, '');
if (createdCardPaths.has(cardPath)) {
response.writeHead(200, { 'content-type': SupportedMimeType.JSON });
Expand All @@ -280,11 +280,11 @@ module('factory-entrypoint integration', function () {
response.end('not found');
}
} else if (
request.url?.startsWith('/hassan/personal/') &&
request.url?.startsWith('/testuser/personal/') &&
request.method === 'POST'
) {
createdCardPaths.add(
request.url.replace('/hassan/personal/', '').replace(/\.json$/, ''),
request.url.replace('/testuser/personal/', '').replace(/\.json$/, ''),
);
// Card creation — accept it
response.writeHead(204);
Expand All @@ -307,10 +307,10 @@ module('factory-entrypoint integration', function () {
let origin = `http://127.0.0.1:${address.port}`;
let briefUrl = `${origin}/software-factory/Wiki/sticky-note`;
targetRealm = `${origin}/typed-by-user/personal/`;
canonicalTargetRealmUrl = `${origin}/hassan/personal/`;
canonicalTargetRealmUrl = `${origin}/testuser/personal/`;

let tempHome = createTempProfileHome({
username: 'hassan',
username: 'testuser',
matrixUrl: `${origin}/`,
realmServerUrl: `${origin}/`,
password: 'secret',
Expand Down Expand Up @@ -359,7 +359,7 @@ module('factory-entrypoint integration', function () {
'note',
]);
assert.strictEqual(summary.targetRealm.url, canonicalTargetRealmUrl);
assert.strictEqual(summary.targetRealm.ownerUsername, 'hassan');
assert.strictEqual(summary.targetRealm.ownerUsername, 'testuser');
assert.strictEqual(
summary.seedIssue.seedIssueId,
'Issues/bootstrap-seed',
Expand All @@ -386,7 +386,7 @@ module('factory-entrypoint integration', function () {
'factory:go',
'--',
'--target-realm',
'https://realms.example.test/hassan/personal/',
'https://realms.example.test/testuser/personal/',
],
{
cwd: packageRoot,
Expand Down Expand Up @@ -429,7 +429,7 @@ module('factory-entrypoint integration', function () {

try {
let briefUrl = `http://127.0.0.1:${address.port}/software-factory/Wiki/sticky-note`;
let targetRealm = `http://127.0.0.1:${address.port}/hassan/personal/`;
let targetRealm = `http://127.0.0.1:${address.port}/testuser/personal/`;
let result = await runCommand(
'pnpm',
[
Expand Down
10 changes: 5 additions & 5 deletions packages/software-factory/tests/factory-entrypoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { installTestProfile } from './helpers/test-profile';

const briefUrl =
'https://briefs.example.test/software-factory/Wiki/sticky-note';
const targetRealm = 'https://realms.example.test/hassan/personal/';
const targetRealm = 'https://realms.example.test/testuser/personal/';
const normalizedBrief: FactoryBrief = {
title: 'Sticky Note',
sourceUrl: briefUrl,
Expand All @@ -30,7 +30,7 @@ const normalizedBrief: FactoryBrief = {
const bootstrappedTargetRealm: FactoryTargetRealmBootstrapResult = {
url: targetRealm,
serverUrl: 'https://realms.example.test/',
ownerUsername: 'hassan',
ownerUsername: 'testuser',
createdRealm: true,
};
const mockSeedResult: SeedIssueResult = {
Expand All @@ -48,7 +48,7 @@ module('factory-entrypoint', function (hooks) {

function useTestProfile() {
cleanupProfile = installTestProfile({
username: 'hassan',
username: 'testuser',
matrixUrl: 'https://matrix.example.test/',
realmServerUrl: 'https://realms.example.test/',
password: 'secret',
Expand Down Expand Up @@ -236,7 +236,7 @@ module('factory-entrypoint', function (hooks) {
'note',
]);
assert.strictEqual(summary.targetRealm.url, targetRealm);
assert.strictEqual(summary.targetRealm.ownerUsername, 'hassan');
assert.strictEqual(summary.targetRealm.ownerUsername, 'testuser');
assert.deepEqual(
summary.actions.map((action) => action.name),
[
Expand Down Expand Up @@ -395,7 +395,7 @@ module('factory-entrypoint', function (hooks) {

assert.strictEqual(summary.brief.title, 'Sticky Note');
assert.strictEqual(summary.brief.sourceUrl, briefUrl);
assert.strictEqual(summary.targetRealm.ownerUsername, 'hassan');
assert.strictEqual(summary.targetRealm.ownerUsername, 'testuser');
assert.strictEqual(summary.seedIssue.seedIssueId, 'Issues/bootstrap-seed');
assert.strictEqual(summary.issueLoop?.outcome, 'all_issues_done');
assert.strictEqual(summary.result.status, 'completed');
Expand Down
16 changes: 8 additions & 8 deletions packages/software-factory/tests/factory-target-realm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '../src/factory-target-realm';
import { installTestProfile } from './helpers/test-profile';

const targetRealm = 'https://realms.example.test/hassan/personal/';
const targetRealm = 'https://realms.example.test/testuser/personal/';

module('factory-target-realm', function (hooks) {
let cleanupProfile: (() => void) | undefined;
Expand All @@ -27,7 +27,7 @@ module('factory-target-realm', function (hooks) {

function useTestProfile() {
cleanupProfile = installTestProfile({
username: 'hassan',
username: 'testuser',
matrixUrl: 'https://matrix.example.test/',
realmServerUrl: 'https://realms.example.test/',
password: 'secret',
Expand All @@ -48,14 +48,14 @@ module('factory-target-realm', function (hooks) {
'https://realms.example.test/',
'defaults to active profile realmServerUrl when --realm-server-url is not provided',
);
assert.strictEqual(resolution.ownerUsername, 'hassan');
assert.strictEqual(resolution.ownerUsername, 'testuser');
});

test('resolveFactoryTargetRealm accepts an explicit realm server URL override', function (assert) {
useTestProfile();

let resolution = resolveFactoryTargetRealm({
targetRealm: 'https://realms.example.test/boxel/hassan/personal/',
targetRealm: 'https://realms.example.test/boxel/testuser/personal/',
realmServerUrl: 'https://realms.example.test/boxel/',
});

Expand Down Expand Up @@ -83,7 +83,7 @@ module('factory-target-realm', function (hooks) {
test('resolveFactoryTargetRealm rejects when target realm origin does not match profile', function (assert) {
// Profile points to staging, but target realm is localhost
cleanupProfile = installTestProfile({
username: 'hassan',
username: 'testuser',
matrixUrl: 'https://matrix-staging.stack.cards/',
realmServerUrl: 'https://realms-staging.stack.cards/',
password: 'secret',
Expand All @@ -92,7 +92,7 @@ module('factory-target-realm', function (hooks) {
assert.throws(
() =>
resolveFactoryTargetRealm({
targetRealm: 'http://localhost:4201/hassan/my-realm/',
targetRealm: 'http://localhost:4201/testuser/my-realm/',
realmServerUrl: null,
}),
(error: unknown) =>
Expand Down Expand Up @@ -180,13 +180,13 @@ module('factory-target-realm', function (hooks) {
let result = await bootstrapFactoryTargetRealm(resolution, {
createRealm: async () => ({
createdRealm: true,
url: 'https://realms.example.test/hassan/personal/',
url: 'https://realms.example.test/testuser/personal/',
}),
});

assert.strictEqual(
result.url,
'https://realms.example.test/hassan/personal/',
'https://realms.example.test/testuser/personal/',
);
});
});